thoughtbot / parity

Shell commands for development, staging, and production parity for Heroku apps
https://thoughtbot.com
MIT License
889 stars 57 forks source link

Feature request: add flag to use the downloaded database #189

Open tannakartikey opened 3 years ago

tannakartikey commented 3 years ago

I have frequently come across situations during the development where I have to restore the development database multiple times in a short time, where it does not make sense to download the remote database again.

If the maintainers think that the option to use the already downloaded database will help, I can work on the same.

geoffharcourt commented 3 years ago

Hi @tannakartikey I think this is a great idea, please go ahead with a pull request.

tannakartikey commented 2 years ago

@geoffharcourt I was thinking to introduce --cached flag to convey that the user wants to restore from the database downloaded earlier.

At the moment, the local database is deleted by the delete_local_temp_backup method after the database is restored. What should we do about it?

https://github.com/thoughtbot/parity/blob/81893f7ed7307b3464847d3c9e7de90ea8c02766/lib/parity/backup.rb#L40-L47

croaky commented 2 years ago

Possibly some ideas in here https://dancroak.com/heroku-postgres-restore-staging-development which is based originally on Parity code. My shell history frequently contains lines like:

db-restore-stag-from-prod-backup && db-backup-stag && db-download-stag-backup && db-restore-dev-from-downloaded-backup

The use case you described is the last command since there's a tmp/latest.backup sitting on the filesystem:

db-restore-dev-from-downloaded-backup

I'd recommend flagging delete_local_temp_backup as you say and considering whether the default should be to keep the backup on the filesystem.