Skip to content

fix: add ON DELETE cascade/set-null rules to FK relationships#198

Open
jakebromberg wants to merge 2 commits intomainfrom
fix/38-fk-cascades
Open

fix: add ON DELETE cascade/set-null rules to FK relationships#198
jakebromberg wants to merge 2 commits intomainfrom
fix/38-fk-cascades

Conversation

@jakebromberg
Copy link
Member

Summary

  • Most FK relationships in wxyc_schema tables defaulted to ON DELETE NO ACTION, blocking legitimate operations like deleting users or schedule entries when child rows exist.
  • Added onDelete: 'set null' to 8 FK columns where the child row should be preserved (schedule DJ assignments, flowsheet entries, show primary DJ, shift cover DJ).
  • Added onDelete: 'cascade' to 7 FK columns where the child row is meaningless without the parent (rotation/review entries, cross-reference tables, show_djs.show_id).
  • Left 4 FK columns as NO ACTION intentionally (library → artists/genres/format, artists → genres) to block deletion when albums/artists still reference them.
  • Added unit test (tests/unit/database/schema.fk-cascades.test.ts) that asserts correct onDelete rules for all 19 FK relationships.

Test plan

  • Unit test verifies all 15 FK columns have the correct onDelete rule
  • Unit test verifies 4 FK columns intentionally lack onDelete (NO ACTION)
  • Generate and review migration before applying to production DB

Closes #38

Made with Cursor

Most FK relationships defaulted to NO ACTION, blocking legitimate
operations like user deletion. Added appropriate cascade rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant