Reputation: 541
I need to add a property/column to a table in a production database(Postgre) on Heroku.com (Rails app) by doing migration. When I do the migration it looks ok, but when I view the columns on the table it has has not added the column!
My development db is sqlite3 and the production db is postgre
I do the following:
heroku run rails generate migration AddUtc_OffsetToEvents utc_offset:integer RAILS_ENV=production --app app-name-1111
and it returns:
invoke active_record
create db/migrate/20130304070946_add_utc_offset_to_events.rb
And then I run the migration
heroku run rake db:migrate RAILS_ENV=production --app app-name-1111
And then:
heroku restart
When I run
heroku pg:psql HEROKU_POSTGRESQL_GRAY_URL --app app-name-1111
and check the columns of the table:
\d+ events
It still does not have the utc_offset column, and no errors are displyed while doing the previous cmds.
Any ideas or hints?
Upvotes: 0
Views: 219
Reputation: 1262
Why not just download the code, add the migration and push the changes ? After, just run the heroku run rake db:migrate on the app.
Upvotes: 0
Reputation: 2961
It looks like you are doing several calls to heroku run
Each time you do heroku run
it spins up a completely new dyno with your latest code, and when run is over that dyno is destroyed. So the second heroku run does not have the migration filed created in the first.
Since you are already familiar with psql you can just use ALTER TABLE
directly. Otherwise you'll need to check your migration into your code and git push heroku master
it to heroku, then run it.
Upvotes: 2