Commit d6fa8ed
committed
fix(schema): predecessor_memory_id ON DELETE CASCADE (review #4)
Hard-deletes (e.g. resetBySource in repository-write) silently nulled
out predecessor_memory_id pointers, breaking backward chain traversal
and leaving half-broken chains where some events still reference a
deleted ancestor.
Change the predecessor FK to ON DELETE CASCADE so the dependent chain
node gets removed cleanly when its predecessor goes. Matches the
memory_id FK policy on the same table.
Schema migration runs an idempotent DROP CONSTRAINT / ADD CONSTRAINT in
a DO block because CREATE TABLE IF NOT EXISTS won't update column-level
FK definitions on an existing table.1 parent 4020135 commit d6fa8ed
1 file changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
356 | 378 | | |
357 | 379 | | |
358 | 380 | | |
| |||
0 commit comments