autogenerate wants to add existing named index

Issue #282 resolved
dan milon
created an issue

I've got the following index

Index(EMAIL_UNIQUE_CONSTRAINT_NAME, func.lower(email), unique=True)

and even though it already exists in the database, a new revision tries to create it again.

op.create_index('user_email_unique', 'user', [sa.text('lower("user".email)')], unique=True)

I think autogenerate is able to catch these kind of indexes. Am I doing something wrong?

Comments (6)

  1. Michael Bayer repo owner

    can you please share:

    1. the target database in use (mysql, Postgresql, etc.)

    2. ensure you're on the latest alembic

    3. have you tried the latest master of alembic? there's a MySQL-related fix to unique indexes that is yet unreleased.

  2. Michael Bayer repo owner
    • Postgresql "functional" indexes are necessarily skipped from the autogenerate process, as the SQLAlchemy backend currently does not support reflection of these structures. A warning is emitted both from the SQLAlchemy backend as well as from the Alembic backend for Postgresql when such an index is detected. fixes #282

    → <<cset 46761f9d868c>>

  3. Log in to comment