-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
see if we can enable CHECK constraint reflection in batch mode, perhaps w/ flag if it interferes w/ boolean/enum #884
Comments
well, it looks like the last time i documented things on batch, SQLAlchemy didn't reflect check constraints at all: "SQLAlchemy currently doesn’t reflect CHECK constraints on any backend." from https://alembic.sqlalchemy.org/en/latest/batch.html#including-check-constraints , but then on SQLAlchemy it looks like we added them in 1.1. However, the comment above is actually referring to a different issue which is that we can't distinguish these CHECK constraints from the ones SQLAlchemy creates automatically for Boolean and Enum datatypes. SQLAlchemy 1.4 turns off that default behavior as it has been nothing but trouble for alembic. Basically it seems like we should look into enabling the above block, perhaps with some conditional. If devs want to work on this or people have PRs, that would help. In the meantime, you can send the CheckConstraint object to the directive manually as illustrated at https://alembic.sqlalchemy.org/en/latest/batch.html#including-check-constraints. |
so your case passes if i take that code out, but the tests dont. seeing if i can disinguish these cases. |
yeah it is exactly this: "we have no way to determine _is_type_bound() for these." still looking |
OK i have something that will work, it will be for 1.7 and will have a bit of a backwards incompatible change for users renaming or dropping columns that refer to named check constraints; they'll have to refer to these. we will see what the impact is and if we need to add more of an upgrade path. |
Mike Bayer has proposed a fix for this issue in the master branch: support named CHECK constraints in batch https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/3017 |
Describe the bug
With Alembic 1.6.5 and SQLite backend, dropping check constraints will cause
ValueError: No such constraint
error.Expected behavior
It should drop check constraint in batch mode if supported.
To Reproduce
Error
Versions.
Additional context
After my investigation, alembic/operations/batch.py#220 checks
CheckConstraint
and skips them. If I comment out L220 ~ L223, the migration works as expected.However, I knew previous SQLAlchemy could not reflect
CheckConstraint
in SQLite backend. Is this still valid for newer SQLAlchemy? Any suggestions to make droppingCheckConstraint
work with SQLite?The text was updated successfully, but these errors were encountered: