简体   繁体   中英

Heroku and Rails: transferring db to staging and db:migrate

I've been working on a Heroku app for several months. We've recently set up a staging server and occasionally sync the staging db with the production db . The three main commands in use are:

$ heroku pgbackups:capture --app myapp

$ heroku pg:reset DATABASE --app myapp-staging --confirm myapp-staging"

$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging

The problem is that after running the third command, I need to run heroku run rake db:migrate --app myapp-staging . We have a few dozen migrations now, including some that refer to Ruby classes that we've deleted or renamed.

This causes the migrations to fail to fully run. What's the solution here? Should I delete the old migrations that fail and commit these changes to the git repo?

You can also checkout the transfer command now as part of pgbackups .. see this post

How do I transfer production database to staging on Heroku using pgbackups? Getting error

Re-running this script fixed the error, so it seems like the schema should just copy over. For anyone seeing a failing migration like I did, the pgbackups:restore command probably failed for you, so re-run that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM