Closed waynegraham closed 3 years ago
Need to export individual table data, reset the database, and reinsert the data. There were some missing columns in the User
object in this migration as well.
heroku pg:backups:capture
)heroku pg:backups:download
)pg_restore --verbose --clean --no-acl --no-owner -h localhost -U `whoami` -d mydb latest.dump
pg_dump --column-inserts --data-only --table=proposals participatory_voter_development > proposals.sql
pg_dump --column-inserts --data-only --table=users participatory_voter_development > users.sql
pg_dump --column-inserts --data-only --table=votes participatory_voter_development > votes.sql
Then delete the tables locally and fix.
See https://devcenter.heroku.com/articles/heroku-postgres-import-export#import-to-heroku-postgres
To restore, you need a dump file somewhere with a URL (like AWS with resigned URL):
aws s3 presign s3://your-bucket-address/your-object
Then, use pg:backup:restore
heroku pg:backups:restore '<SIGNED URL>' DATABASE_URL
This method ran into issues. Ended up manually fixing the migrations table to reflect the new dates:
DELETE FROM schema_migrations;
select * from schema_migrations;
INSERT INTO schema_migrations VALUES (20200415142945);
INSERT INTO schema_migrations VALUES (20200414162703);
INSERT INTO schema_migrations VALUES (20200415134236);
INSERT INTO schema_migrations VALUES (20200415145413);
INSERT INTO schema_migrations VALUES (20200415152813);
INSERT INTO schema_migrations VALUES (20200421182813);
There is an issue with the database migrations which generates the following error:
This isn't presenting a problem as the database schema hasn't changed, just the in the migrations.