I'm trying to copy my production database on Heroku across to my staging server.
My staging server has been ahead of my production server with a migration that creates an extra table. I now want to dry-run the migration to add that table on the production database and so would like to revert my staging's database in order to do so.
The problem is that each time I restore
the staging database to the production one the table sticks around. I was expecting the database to be destroyed and repopulated but it only seems to be being repopulated.
heroku pgbackups:url b104 --app production
# 'http://s3.amazonaws.com/...'
heroku pgbackups:restore DATABASE 'http://s3.amazonaws.com/...' --app staging
Every time I do this I find that the "newer" table is still remaining.
Does pgbackups:restore
actually restore table structure or simply data - what's going on here?
As per Heroku's docs: In order for PG Backups to access and import your dump file you will need to upload it somewhere with an HTTP-accessible URL. Keep in mind the URL should be a downloadable link as in the mentioned question.
Snapshots are stored directly in AWS's S3 object store. Base backups and WAL files are pushed to' S3 through an application called WAL-E as soon as they are made available by Postgres. All databases managed by Heroku Postgres provide continuous protection by persisting snapshots, base backups and WAL files to S3.
A restore is a simple Postgres restore, so essentially a scripted version of your data.
In order to do this, you need to nuke your database first, and then rebuild it from the database script:
heroku pg:reset
heroku pgbackups:restore blah...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With