Postgres Heroku no longer overwrites config / database.yml Rails 4.1.4 (and other questions)

I am very new to RoR and am having a hard time figuring out how to properly configure and use Heroku Postgres with my Rails 4.1.4 application. I am on Ubuntu 14.04.1 LTS.

I want to have local PostgreSQL databases for development and testing, and Heroku Postgres database for production.

Here's what I've done so far:

  • I am setting up PostgreSQL following the heroku official doc here
  • I installed the pg

    gem
  • I changed the file config/database.yml

    :

    default: &default
      adapter: postgresql
      encoding: unicode
      pool: 5
      timeout: 5000
      username: franklin
      password:
    
    development:
      <<: *default
      database: myapp_development
    
    test:
      <<: *default
      database: myapp_test
    
    production:
      url: <%= ENV["DATABASE_URL"] %>
    
          

    I know from here that Heroku no longer overwrites config/database.yml

    for Rails 4.1.x apps and what should I (should?) Specify DATABASE_URL

    in the production record.

  • I ran rake db:create:all

    which created local dev and test bases and thenrake db:migrate

  • i git commit

    change and then push my app to Heroku withgit push heroku master

  • I ran heroku run rake db:migrate

    and got the following message: Running rake db:migrate attached to terminal... up, run.1227

    (I'm not sure what this means?)
  • Finally I ran heroku restart

Then, when I connect to my development database, I see the new table created by the command rake db:migrate

, as well as its new data (form view) that I intentionally created by running my application at localhost: 3000. I get the completely expected behavior.

But when I connect to my Heroku Postgres production database, the new table that the command should have created heroku run rake db:migrate

does not exist. And Heroku app doesn't crash when I add data to a non-existent table (form view).

Here are my questions:

  • Is my product input set up correctly config/database.yml

    ?
  • How do I properly migrate to my Heroku Postgres production database?
  • Where does the data from my Heroku app go if not in the table?

Any help would be greatly appreciated! Thank!

+3


source to share


1 answer


You need to go to https://postgres.heroku.com/databases

Search for your application's database and you will find the matching keys for your database. You can load them as config variables and load them into yourdatabase.yml



Have a look at figaro for easy handling of your config variables.

+1


source







All Articles