You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(db): migration-release reconciliation misses constraints from already-applied migrations #456
packages/db/tests/migration-release.test.ts › database release > does not silently baseline a missing webhook ownership constraint fails whenever exactly one new migration is pending and an earlier, already-applied migration is the one that actually owns the missing object.
Repro path found while investigating CI on #448: that PR adds 0027_friendly_bloodaxe.sql (the ai_usage table). The test drops webhook_delivery_processing_claim_check, a constraint created by 0026_breezy_johnny_storm.sql, then removes the latest migration from the ledger and runs releaseDatabase() expecting the constraint to be restored.
With only 0027 pending, reconcileNotificationChecks() (or the equivalent reconciliation step) is only given the pending migrations to work from. Since 0026 is already recorded as applied, the missing constraint it owns is invisible to reconciliation, and the constraint never gets recreated. This isn't specific to 0027 or to the AI provider work in #448, any PR that adds the next migration on top of main will trip the same test, since the failure depends on which migration is "latest" at merge time, not on anything the new migration itself does.
Root cause looks like reconciliation scoping itself to pending migrations only, when it needs to check the full set of declared schema objects regardless of which migration originally created them (consistent with how bun run db:release is documented to compare columns, types, defaults, indexes, foreign keys, etc. against the declared schema as a whole, not migration-by-migration).
Activity
fix(db): reconcile schema objects against all migrations during basel…