node-database-cleaner
node-database-cleaner copied to clipboard
Postgres tables not cleaning
A few problems came up for us:
-
When
database-cleanerlists out the tables to be deleted, the tables are not ordered by foreign key constraints. So we havechildwith a foreign key toparent, butDELETE FROM "parent"is attempted to be run beforeDELETE FROM "child", causing the table to not be deleted because there are still rows inchildreferencingparent -
When the above command didn't work,
database-cleanersilently failed. I believedatabase-cleanershould check that the table was indeed cleared, and error otherwise.
Truncation seems to work for us. Is there a reason why truncation is not the default?
@brandon-leapyear not exactly. Can you send a PR? Thanks