title: How to run migrations on a different database server through Heroku?
body: <p>We need to add the credentials of a database in <code>database.yml</code> file under a different environment like <code>remote_database</code>:</p>
  
  <pre><code>remote_database:
    adapter:
    encoding:
    username:
    ...
  </code></pre>
  
  <p>And after adding all this, running the following command from the local terminal does the job:</p>
  
  <pre><code>RAILS_ENV=remote_database rails db:migrate
  </code></pre>
  
  <p>I'm trying to accomplish the same thing on Heroku. I have pushed the changes in <code>config/database.yml</code>, and I'm trying to execute the following command:</p>
  
  <pre><code>RAILS_ENV=remote_database heroku run rake db:migrate
  # or
  heroku run rake db:migrate RAILS_ENV=remote_database
  </code></pre>
  
  <p>Seems like Heroku is completely ignoring <code>RAILS_ENV</code> or the settings for <code>remote_database</code> env in <code>config/database.yml</code> file. Heroku always makes the changes in the regular database server connected with it that can be found at <code>DATABASE_URL</code>.</p>
  
  <p>Is there a way to run the migrations on a different database server through Heroku?</p>