A raw campaign DELETE works: quest_objectives' FK is deferred (#943) #957
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/943-quest-objectives-fk"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #943.
Diagnosis confirmed: reproduced on main. A raw
DELETE FROM campaignsfails when an objective has adone_session_id. The row is reached by two paths in one statement:quest_objectives.lore_entry_id → quest_details.lore_entry_id;sessions.The SET NULL update then references a
quest_detailsrow that is already being deleted.Fix: migration
a9430d1e2f3b(down_revision10e5f6a7b8c9, the single head) recreatesquest_objectives_lore_entry_id_fkeywith the same column, target andON DELETE CASCADE, nowDEFERRABLE INITIALLY DEFERRED. Downgrade restores it as not deferrable. The model'sForeignKeymatches. Deferring that one constraint was enough.The seed's workaround is gone:
_delete_lane8_firstwas removed fromdemo/engine.py, anddelete_demo's singleDELETE FROM campaignsnow covers everything, the GM copy (#954) included.Tests:
test_quest_objectives_fk_migration.py(new):SET CONSTRAINTS ALL IMMEDIATEbecause the test rolls back. It fails on main.upgrade/downgrade/upgradein a scratch schema, checkingcondeferrableandcondeferred.test_test_usage_migration.py's head pin is loosened to "the revision exists".quest_objectives|QuestObjective|delete_demo|_migration, plus the seed, passed (1071).test_demo_seed, the new file and the usage-migration test pass (21).pg_constraintshowing it deferrable and deferred.changelog.py checkpasses.Changelog:
changelog.d/943-quest-objectives-fk.fixed.md.🤖 Generated with Claude Code