I spent the better part of today struggling with Rails while upgrading some old code. Documenting this here in order to hopefully save others the time.
In a case where you have three tables, e.g. Wizard
, Dungeon
, and DungeonWizard
, where DungeonWizard
is the join table, you cannot make the foreign keys in DungeonWizard
constrained to not null.
In the below code, if you run these statements:
The output is:
Notice the INSERT
followed by the UPDATE
? This breaks when there is a null constraint on the join table.
Code: