Open danizen opened 2 years ago
Another way to mitigate this would be to mention it in the documentation as a warning.
The actual result was that dump worked, but load failed with a referential integrity error.
Thanks for the report :+1: . Feel free to open a PR implementing this.
This can be done using the built-in dumpdata by passing the -a
/--all
flag:
./manage.py dumpdata --all myapp
That causes dumpdata to use the base manager rather than the default manager, and results in safe-deleted objects being included in the dump.
We had a situation arise with an application written in 2017 using a home-grown ModelManager which works similarly to the SafeDeleteManager. Because we are migrating from one database to another, and there is not too much data, we attempted to use the management commands dumpdata and loaddata to copy the data to the new database instance.
This caused referential integrity errors because dumpdata did not include the deleted models. My suggestion is that safedelete includes its own dumpdata command which avoids the problem: