There are a number of posts that recommend directly updating the Heroku database; this one, for example. I started to take this approach and then realized that there was a safer way to make this change. Heroku has a set of database commands that allow you to copy your production database down to your location machine or copy it back to production. This is better, IMO, than mucking with production data live... even with a backup. Working on your local machine, you can run your tests and generally use all available tools to make sure the modifications work before you upload it back to production.
The steps are dead simple:
- Find the id of your production database:
heroku config --app [name]
the id you want is usually something like "HEROKU_POSTGRESQL_PINK_URL"where "PINK" will probably be some other color. - Make a backup of your production database using the database id:
heroku pgbackups:capture --app [name] [database id]
- "Pull" the production database down to your local machine (Heroku drops it into your development database):
heroku db:pull --app [name]
- Make your changes
- Run your tests
- "Push" the modified data back to production:
heroku db:push --app [name]
- Open your browser and run a smoke test on your updated database.
No comments:
Post a Comment