title: Rails database complain non exist on production only (with db:migrate succeeded)
body: <h1>Setup</h1>
  
  <p>Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.2.6'
  gem 'dotenv-rails', :require =&gt; 'dotenv/rails-now'
  # Use PostgreSQL as the database for Active Record
  gem 'pg'
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 5.0'
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 1.3.0'
  # Use CoffeeScript for .coffee assets and views
  gem 'coffee-rails', '~&gt; 4.1.0'
  # See https://github.com/rails/execjs#readme for more supported runtimes
  # gem 'therubyracer', platforms: :ruby
  
  gem 'sprockets-rails', '2.3.3'
  
  # Use jquery as the JavaScript library
  gem 'jquery-rails'
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
  gem 'turbolinks'
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 2.0'
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  
  # Use ActiveModel has_secure_password
  # gem 'bcrypt', '~&gt; 3.1.7'
  
  # Use Unicorn as the app server
  # gem 'unicorn'
  
  # use puma as app server
  gem 'puma'
  
  # Use Capistrano for deployment
  # gem 'capistrano-rails', group: :development
  
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    # conflict in RubyMine
    gem 'byebug'
    gem 'sqlite3'
  end
  
  group :development do
    # Access an IRB console on exception pages or by using &lt;%= console %&gt; in views
    gem 'web-console', '~&gt; 2.0'
  
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'
  
    # generate ERD
    gem 'rails-erd'
  
    gem 'guard', '&gt;= 2.2.2', :require =&gt; false
    gem 'guard-minitest', :require =&gt; false
    gem 'letter_opener'
  end
  
  group :test do
    gem 'minitest-reporters'
    gem 'minitest-spec-rails'
    gem 'resque_unit'
  end
  
  gem 'interactor-rails', '~&gt; 2.0'
  gem 'dotenv'
  gem 'ooor'
  gem 'resque'
  gem 'resque-retry'
  gem 'resque-logger'
  gem 'resque-history'
  gem 'resque-scheduler' 
  gem 'resque-web', require: 'resque_web'
  gem 'resque-scheduler-web'
  gem 'net-sftp'
  gem 'nokogiri'
  gem 'rubyzip'
  gem 'aws-sdk'
  
  gem 'resque_mailer'
  </code></pre>
  
  <p>database.yml:</p>
  
  <pre><code>default: &amp;default
    adapter: postgresql
    encoding: unicode
    pool: 5
  
  development:
    &lt;&lt;: *default
    adapter: sqlite3
    database: db/development.sqlite3
    pool: 5
    timeout: 5000
  
  test:
    &lt;&lt;: *default
    adapter: sqlite3
    database: db/test.sqlite3
    pool: 5
    timeout: 5000
  
  staging:
    &lt;&lt;: *default
    database: &lt;%= ENV['DATABASE_NAME'] %&gt;
    username: &lt;%= ENV['DATABASE_USER'] %&gt;
    password: &lt;%= ENV['DATABASE_PASSWORD'] %&gt;
  
  production:
    &lt;&lt;: *default
    database: &lt;%= ENV['DATABASE_NAME'] %&gt;
    username: &lt;%= ENV['DATABASE_USER'] %&gt;
    password: &lt;%= ENV['DATABASE_PASSWORD'] %&gt;
  </code></pre>
  
  <p>.env.production:</p>
  
  <pre><code>DATABASE_NAME='rapid_tunnel_production'
  </code></pre>
  
  <h1>The Problem</h1>
  
  <ol>
  <li><p>When I do: <code>RAILS_ENV=production rake db:create db:migrate</code>, it works perfectly fine</p></li>
  <li><p>When I do: <code>rails s -e production</code>, in <code>log/production.log</code>, I have error:</p>
  
  <pre><code>I, [2016-05-03T15:50:47.819743 #4932]  INFO -- : Started GET "/favicon.ico" for ::1 at 2016-05-03 15:50:47 +0800
  F, [2016-05-03T15:50:47.825279 #4932] FATAL -- :
  ActiveRecord::NoDatabaseError (FATAL:  database "rapid_tunnel_production" does not exist
  ):
    activerecord (4.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect'
    activerecord (4.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
    activerecord (4.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
    activerecord (4.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
    activerecord (4.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
    /Users/songyy/.rvm/rubies/ruby-head/lib/ruby/2.3.0/monitor.rb:211:in `mon_synchronize'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
    /Users/songyy/.rvm/rubies/ruby-head/lib/ruby/2.3.0/monitor.rb:211:in `mon_synchronize'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
    activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
    activerecord (4.2.6) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
    activerecord (4.2.6) lib/active_record/connection_handling.rb:87:in `connection'
    activerecord (4.2.6) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
  </code></pre></li>
  </ol>
  
  <h1>Question</h1>
  
  <p>Any idea why this happens?</p>