Skip to content

Commit

Permalink
fix(database_cleanup): endless loop
Browse files Browse the repository at this point in the history
I had a case where database_cleanup looped endlessly because of
referential integrity. DROP TABLE was failing because 2 tables had
mutual foreign keys, and the error message suggested using
DROP TABLE ... CASCADE, which indeed fixed the problem.
  • Loading branch information
gurneyalex committed Mar 28, 2022
1 parent 21dce2d commit a6f5521
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion database_cleanup/models/purge_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def purge(self):
)

self.logger.info("Dropping table %s", line.name)
self.env.cr.execute("DROP TABLE %s", (IdentifierAdapter(line.name),))
self.env.cr.execute("DROP TABLE %s CASCADE", (IdentifierAdapter(line.name),))
line.write({"purged": True})
return True

Expand Down

0 comments on commit a6f5521

Please sign in to comment.