I'm having some issue with my migrations in Heroku. I've tried several things but none seem to work. I feel like I should just drop the table that's causing the issue, which will delete all the data in production.
If I drop the table, and re-created the table, will I be able to restore all of the data I lost? Because I will backup my database on Heroku before I drop the table.
Thanks!
You should run a backup with
Then, after you have dropped and re-created the table, you can restore the data with
However, this will not work if the table structure has changed.
In that case, you might want to use
COPY
directly to write the data to a file and restore them from there.Let's for example assume you plan to add another column. Then you could dump with
After the table was created with the new column, you can
The new column will be filled with the NULL values.
Modify this basic recipe for more fancy requirements.