-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Autogenerate does not support Operator classes for postgres #1327
Comments
@CaselIT this is more expression based indexes not comparing correctly. I think we need an option to flat out turn off PG index comparison and I think it has to be off by default. what do you think? |
The fact that operation class is not detected like that is the expected behavior, since operator classes should be specified as documented here https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#operator-classes that said this the detection will be skipped for json based indexes so we can keep it open for that fix |
I can give the postgresql_ops a try and see what that gives me |
Using postgresql_ops generates the index correctly the first time. However immediately rerunning another autogenerate after applying the first migration detects a difference on jsonb_path_ops and generates another change. This is my updated table/index definition:
|
yes, that's the bug in the detection that I mentioned. Can you post the updated info log on alembic? |
Federico Caselli has proposed a fix for this issue in the main branch: More PostgreSQL expression index compare fixes https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4912 |
Describe the bug
For data types that support Operator classes in postgres, such as jsonb and jsonb_path_ops, alembic does not load the operator class from the database during autogenerate detection.
Table definition:
Running autogenerate logs this:
Expected behavior
Alembic should not detect a change in this index since it is already in the database correctly.
Versions.
Additional context
In SQL alchemy 1.x we used to just get warnings that it couldn't read functional indexes. Now in 2.0 it tries to re-create the index without the operator classes (jsonb_path_ops)
Have a nice day!
The text was updated successfully, but these errors were encountered: