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
Wrong index detection on cockroachdb #1356
Comments
this is some issue with both index reflection and something with the driver itself that is out of scope for alembic, that error message is unknown to us here so you'd want to ask on the sqlalchemy-cockroachDB driver tracker, cc @gordthompson |
this is similar to the other issue with expression reflection. you are placing order modifying in the expression. |
Alembic is doing that class Account(Base):
__tablename__ = "account"
account_number = Column(Integer, primary_key=True)
customer_name = Column(String(50))
invoices = relationship("Invoice", back_populates="account")
Index("ix_account_customer_name", customer_name.nullsfirst()) running
produced a revision file that included op.create_index('ix_account_customer_name', 'account', [sa.text('customer_name NULLS FIRST')], unique=False) That said, I am unable to reproduce the issue against CockroachDB using psycopg2, and if I try using asyncpg then Alembic doesn't like it at all:
|
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 |
Additional fixes to PostgreSQL expression index compare feature. The compare now correctly accommodates casts and differences in spacing. Added detection logic for operation clauses inside the expression, skipping the compare of these expressions. To accommodate these changes the logic for the comparison of the indexes and unique constraints was moved to the dialect implementation, allowing greater flexibility. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1321 Fixes: #1327 Fixes: #1356 Change-Id: Icad15bc556a63bfa55b84779e7691c745d943c63
Hi, I'm trying to make a migration on my cockroachdb DB + sqlmodel.
when I first init alembic and create DB everything works, if I scan again (alembic revision --autogenerate) for possible changes, alembic prints "Detected changed index 'ix_file_bucket' on 'file': expression ('INDEX', 'bucket nulls first') to ('INDEX', 'bucket')" (I didn't change anything in code and database)
and alembic creates the following migrations:
the next time the alembic is triggered, it fails.
with the message:
sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.ObjectNotInPrerequisiteStateError'>: index "ix_file_bucket" is cancelled, try again later
is there any way to solve this? currently I have to manually delete bad migrations line every time.
Versions.
The text was updated successfully, but these errors were encountered: