I have a development database on my computer and a production database on Heroku. I need to run a migration on the production database, to clear certain data, that I don't want to run on the development one. So far I've only been doing migrations that I've wanted to run on both, so I just create it on my computer, run it, then when I upload to Heroku I run it on there too. How can I do a migration only on the production database? Thanks for reading.
views:
36answers:
3
+2
A:
- Create your migration.
- Commit, push, run on heroku with
heroku rake db:migrate --app myapp
. - Comment out the contents of the
up
block. - Run the (now-empty) migration locally.
- Uncomment or git checkout/reset to get back to normal.
This way both your local db and production db will consider the migration to have been run and not try to run it again.
tfe
2010-10-09 21:05:09
A:
Migrations are intended to update the structure of your database, not to manipulate data. If you want to manipulate data, you should use the console or a script.
$ heroku console
Simone Carletti
2010-10-09 21:08:49