reordering scripts is a nightmare to maintain once u add more tables. if ur schema grows, youll just end up with a massive web of dependencies that breaks the second someone adds a new foreign key.
deleting and recreating the relationship as nullable is much safer . i usually just make the
org_id
on the
users
table
nullable for the seed run, then run a separate update script to link them up after the bulk inserts are done. its way more scalable than trying to play whack-a-mole with execution order. ⚠
>the fix is just deferring constraints or reordering the scriptthis assumes u even have control over the constraint settings in ur production migration files. do you actually use
DEFERRABLE
on those FKs, or are you manually toggling them in the seed session?