I need to delete all data from all tables each and every time a Unit Test is fired. Right now I'm using
TRUNCATE TABLE "table_name" CASCADE
for each table that is included in the test suite.
The problem is that those queries take a lot of time - about 9-11 seconds!
I would like to be able to replace those TRUNCATE...CASCADE
with just TRUNCATE
statements, but to do that I need a list of tables ordered by the master-detail (parent-child) relationship (children first). Manually I could create such a list once or twice, but the database changes everyday. Is there a way to generate a list of tables in that order?
I'm using Postgresql.