title: Apartment::SchemaNotFound when trying to deploy multi-tenancy Rails app on Heroku
body: <p>I have been working on an app locally for a while now, and I've matched my development environment to that on Heroku as closely as I can.</p>
  
  <p>The app is set up for multi-tenancy using Apartment (<a href="https://github.com/influitive/apartment" rel="nofollow">https://github.com/influitive/apartment</a>), and designed to use subdomains to identify tenants. Both environments use postgres, and Apartment has been using schemas to manage the 'tanants' data.</p>
  
  <p>This evening, I have attempted to push the code to Heroku (the same app before it became multi-tenancy worked beautifully), and no pages load, all give an error.</p>
  
  <p>I've taken a look at the logs, and the most interesting line I can find is; <code>Apartment::SchemaNotFound (One of the following schema(s) is invalid: heroku-app-name, "public"):</code></p>
  
  <p>This certainly seems to be a peculiarity of Heroku, but I'm struggling for ideas on where to look next.</p>
  
  <p>Any suggestions or help would be appreciated.</p>
  
  <p>I've included all of the logs for reference;</p>
  
  <pre><code>2014-04-04T18:27:09.884367+00:00 app[web.1]: Apartment::SchemaNotFound (One of the following schema(s) is invalid: heroku-app-name, "public"):
  2014-04-04T18:27:09.884368+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/postgresql_adapter.rb:95:in `rescue in connect_to_new'
  2014-04-04T18:27:09.884384+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
  2014-04-04T18:27:09.884362+00:00 app[web.1]:
  2014-04-04T18:27:09.884385+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
  2014-04-04T18:27:09.884364+00:00 app[web.1]: I, [2014-04-04T18:27:09.879482 #2]  INFO -- : Started GET "/favicon.ico" for 92.25.163.224 at 2014-04-04 18:27:09 +0000
  2014-04-04T18:27:09.884388+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  2014-04-04T18:27:09.884389+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/flash.rb:241:in `call'
  2014-04-04T18:27:09.884366+00:00 app[web.1]: F, [2014-04-04T18:27:09.884136 #2] FATAL -- :
  2014-04-04T18:27:09.884370+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/postgresql_adapter.rb:88:in `connect_to_new'
  2014-04-04T18:27:09.884381+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
  2014-04-04T18:27:09.884371+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/abstract_adapter.rb:100:in `switch'
  2014-04-04T18:27:09.884383+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
  2014-04-04T18:27:09.884396+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
  2014-04-04T18:27:09.884372+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/elevators/generic.rb:20:in `call'
  2014-04-04T18:27:09.884387+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
  2014-04-04T18:27:09.884398+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  2014-04-04T18:27:09.884403+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  2014-04-04T18:27:09.884391+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
  2014-04-04T18:27:09.884392+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
  2014-04-04T18:27:09.884399+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__2212192162733263500__call__callbacks'
  2014-04-04T18:27:09.884400+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
  2014-04-04T18:27:09.884393+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/cookies.rb:486:in `call'
  2014-04-04T18:27:09.884402+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  2014-04-04T18:27:09.884406+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  2014-04-04T18:27:09.884379+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
  2014-04-04T18:27:09.884395+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/query_cache.rb:36:in `call'
  2014-04-04T18:27:09.884409+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `block in call'
  2014-04-04T18:27:09.884407+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:38:in `call_app'
  2014-04-04T18:27:09.884410+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `block in tagged'
  2014-04-04T18:27:09.884404+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  2014-04-04T18:27:09.884430+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `tagged'
  2014-04-04T18:27:09.884431+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `call'
  2014-04-04T18:27:09.884432+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  2014-04-04T18:27:09.884428+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:25:in `tagged'
  2014-04-04T18:27:09.884435+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
  2014-04-04T18:27:09.884444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call'
  2014-04-04T18:27:09.884434+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
  2014-04-04T18:27:09.884437+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  2014-04-04T18:27:09.884442+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call'
  2014-04-04T18:27:09.884445+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
  2014-04-04T18:27:09.884448+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
  2014-04-04T18:27:09.884446+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
  2014-04-04T18:27:09.884450+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  2014-04-04T18:27:09.884451+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  2014-04-04T18:27:09.884452+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
  </code></pre>