Marked as helpful by the asker
Your foreign keys to auth.users were created without an on delete rule, so Postgres refuses. Decide per table:
-- their own stuff disappears with them
alter table posts drop constraint posts_author_id_fkey,
add constraint posts_author_id_fkey foreign key (author_id)
references auth.users(id) on delete cascade;
-- keep the row, lose the link (column must be nullable)
alter table comments drop constraint comments_author_id_fkey,
add constraint comments_author_id_fkey foreign key (author_id)
references auth.users(id) on delete set null;Find them all at once:
select conrelid::regclass, conname from pg_constraint
where confrelid = 'auth.users'::regclass;For a GDPR-style deletion, cascade on their personal data is usually what you want.
Nice query for finding all constraints, stealing it. sven_fire · edited
6 constraints fixed via one migration, user deleted. Thanks both tariq_builds · edited