fix(migrate): honor @onDelete/@onUpdate declared on identity.reference#65
Merged
Merged
Conversation
`meta migrate` only resolved FK referential actions from a correlated `relationship` node — an `@onDelete`/`@onUpdate` authored directly on the `identity.reference` (which IS the FK) was silently ignored, so a reference declared `@onDelete: cascade` emitted a bare FK with no ON DELETE clause. resolveReferentialActions now reads the action from the reference first, then falls back to a correlated relationship's explicit action / subtype default. MetaReferenceIdentity gains `onDelete`/`onUpdate` getters. "setnull" is accepted as an alias for the canonical "set-null". Adds reference-level regression tests (resolve + end-to-end Postgres DDL). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018mjBXyYKk6tbQymzhgMmdB
dmealing
enabled auto-merge
June 21, 2026 21:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
meta migrateresolved FK referential actions only from a correlatedrelationshipnode. An@onDelete/@onUpdateauthored directly on theidentity.reference— which is the construct that defines the FK — was silently ignored. A reference declared@onDelete: cascadeemitted a bare FK (noON DELETEclause), silently dropping cascade intent.Surfaced on a real model where ~150 FKs declare
@onDeleteonidentity.reference: the generated baseline emitted 2ON DELETEclauses instead of ~150, breaking cascading deletes at runtime.Fix
resolveReferentialActionsprecedence is now: (1) action declared on theidentity.reference; (2) correlated relationship's explicit action / subtype default; (3) none.MetaReferenceIdentitygainsonDelete/onUpdategetters (mirrorsMetaRelationship)."setnull"accepted as an alias for canonical"set-null".Tests
setnullalias).identity.reference@onDelete: cascade→ON DELETE CASCADEin emitted Postgres DDL.metadata+migrate-tssuites green (2559 pass, 0 fail).🤖 Generated with Claude Code