feat(migrate): drop orphaned ck_* under migrate_destructive - #355
Merged
Conversation
Leftover ferro-owned CHECKs keep rejecting rows the model now allows, so migrate_updates warns by name and only migrate_destructive (Postgres) removes them. Alembic autogenerate always proposes the same DROP. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Gate: clearRead the full diff. AC for #345 is met.
Merging into |
6 tasks
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.
Summary
A ferro-owned
ck_*that is live but gone from the model (removedCheck(...), ordb_check=Truecleared) stays underconnect(..., migrate_updates=True)and Ferro warns naming it — leftover CHECKs keep rejecting rows the model now allows, so silence is wrong here. On Postgres,connect(..., migrate_destructive=True)drops that named constraint. Destructive implies updates.Remove the
Check(...)and reconnect withmigrate_updates=True:ck_transfer_at_most_one_outflowis still there, and the warning names it. Reconnect withmigrate_destructive=Trueand Postgres drops it. A hand-created CHECK whose name does not start withck_survives both flags.SQLite warns with the constraint name and skips the in-place rewrite (ADR-0014). Alembic autogenerate always proposes the runtime's
DROP CONSTRAINTfor an orphaned ferro name — the destructive gate is connect-time safety only (ADR-0013 / ADR-0011: parity is the SQL, not the flag).Closes #345. Part of #339 (stays open). Blocked-by #344 is already on this branch.
Test plan
cargo test -p ferro-ddl-lowering extra_check/render_check_drop(live-order extras, empty extras, warning text, Postgres DROP, SQLite skip, set-difference-only)cargo test -p ferro-migrate plan_check_drops/emit_sql_with_ir_drop_checkcargo test -p ferro-schema-ir -p ferro-ddl-lowering -p ferro-migratecargo test --no-default-features --features testingFERRO_POSTGRES_URL=… uv run pytest tests/test_table_check_orphans.py tests/test_table_check_rebuild.py tests/test_table_check_reconcile.py --db-backends=sqlite,postgres(52 passed)I-9
Closes #345in this bodyfeatPRD: table-level CHECK constraints (multi-column), auto-migrated #339 left openMade with Cursor