django-dbbackup
django-dbbackup copied to clipboard
dbrestore error
dbrestore fails whenever there has been a new migrations with addition or removal of new fields or tables i.e with slightly different schemas. Error messages are looks like what mentioned below: =>....... Error in db restore: no such table: main.documents_file =>........ Error: constraint does not exist =>......... 'ERROR: relation "public.users_userprofile" does not exist => ........ 'ERROR: schema "public" does not exist => ....... ERROR: constraint "socialaccount_socialapp_site_site_id_2579dee5_fk_django_site_id" of relation "socialaccount_socialapp_sites" does not exist
These kinds or error happens when I want to restore to the previous state which has bit of different schema than the db that we want to restore and vice versa.
To Reproduce
- backup current db
- try to restore to the previous state which has some different schema error will be thrown and restore fails..
- try restoring the earlier/old backed up db to the current sate with some different schema. again error will be thrown and restore fails...
So, Please help me to solve these kinds of issue. I am sure there is a way to solve this. How can we mange backup and restore in any kinds of migration that I have mentioned above?
Versions
Django-dbbackup
- pypi: [3.3.0]
External tools
- Python: [3.7]
- Django: [3.0]
- Postgresql: [12.2]
- OS: [Linux] @psychok7 @ZuluPro @jonathan-s
Please help me out to solve this.
If losing your data is not an issue I think the drop options which will generate a --clean argument for pg_restore should DROP all your tables before recreating them.
But if I understand correctly, you want to copy a table to another one that don't have the same migrations history right ? Because it would cause issues in your application if your models are not aligned with the database structure.