Skip to content

Detect changed Check constraint expressions in migrations#40

Merged
mr-fatalyst merged 1 commit into
mr-fatalyst:mainfrom
ebrake:fix/check-constraint-expression-migrations
Jun 9, 2026
Merged

Detect changed Check constraint expressions in migrations#40
mr-fatalyst merged 1 commit into
mr-fatalyst:mainfrom
ebrake:fix/check-constraint-expression-migrations

Conversation

@ebrake

@ebrake ebrake commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Closes #39

Fixes makemigrations not detecting changes to an existing Check constraint when the constraint name stays the same.

Before this change, the migration diff only compared check constraints by name, so this produced no migration:

Check("age >= 0", name="chk_users_age")

when changed to:

Check("age > 0", name="chk_users_age")

Now the diff detects same-name expression changes and emits:

  1. drop_check for the old constraint
  2. add_check for the new constraint

The drop happens first because the replacement uses the same constraint name.

Reordered logic in crates/oxyde-migrate/src/diff.rs so changed same-name checks can be handled as drop_check then add_check.

Testing

cargo test -p oxyde-migrate --quiet
cargo test --workspace --exclude oxyde-core-py --quiet
uv run --project python --extra dev --no-sync pytest -q python/oxyde/tests/unit/test_migrations_execution.py

@mr-fatalyst mr-fatalyst merged commit d223802 into mr-fatalyst:main Jun 9, 2026
5 checks passed
@ebrake ebrake deleted the fix/check-constraint-expression-migrations branch June 19, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

makemigrations does not detect changed Check constraint expressions

2 participants