Skip to content

Handle or track Postgres renaming of long index names when creating migrations #421

@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by Kuan Butts (@kuanb)

Problem:
Alembic is generating long index names, Postgres is automatically shortening them when they are created, resulting in a situation where Alembic "loses track" of that index. Subsequent revisions will generate a new migration that involves dropping the index Postgres created and attempting to re-insert the original index name (which then gets shortened again, starting the loop over once again).

Here's an example name it's generating:
ix_analysis_module_public_results_new_user_summary_module_run_output

...and here is what it would be altered to by Postgres (due to max character length constraint):
ix_analysis_module_public_results_new_user_summary_mod_4597

It would be useful to either have Alembic check that such a change occurred and track it itself or to allow the user to provide a lookup table that equates a shortened name to a longer name, thus enabling it to connect the two when making new migrations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions