feat(fk): Foreign Key Enforcement — ON DELETE/UPDATE CASCADE, SET NULL, RESTRICT

- Add tkRestrict token to lexer
- Parse ON DELETE CASCADE/SET NULL/RESTRICT and ON UPDATE CASCADE/SET NULL/RESTRICT
  in both table-level and column-level FK constraints
- Add fkOnDelete/fkOnUpdate to ColumnDef and ForeignKeyDef
- Fix table-level FK constraint application (third pass after columns are created)
- Implement enforceFkOnDelete, enforceFkOnUpdate, enforceFkOnChildUpdate helpers
- Wire FK enforcement into DELETE and UPDATE execution paths
- Add 9 regression tests covering all FK actions
This commit is contained in:
2026-05-17 13:02:39 +03:00
parent dc4ad86ee1
commit 2e0969245c
4 changed files with 312 additions and 2 deletions
+2
View File
@@ -85,6 +85,7 @@ type
tkForeign
tkReferences
tkCascade
tkRestrict
tkUnique
tkCheck
tkDefault
@@ -308,6 +309,7 @@ const keywords*: Table[string, TokenKind] = {
"foreign": tkForeign,
"references": tkReferences,
"cascade": tkCascade,
"restrict": tkRestrict,
"unique": tkUnique,
"check": tkCheck,
"default": tkDefault,