diff options
author | Johannes Erdfelt <johannes@erdfelt.com> | 2014-12-04 09:42:46 -0800 |
---|---|---|
committer | Johannes Erdfelt <johannes@erdfelt.com> | 2014-12-04 09:55:07 -0800 |
commit | 22667c19df7e30469b61f901cd6404f5d3a5cc14 (patch) | |
tree | c6f7597b89045d827fd0a8eeae3c7afa71965b38 /alembic/ddl/mysql.py | |
parent | 6d5155de3491b9c52c673de5d07920872cdca808 (diff) | |
download | alembic-22667c19df7e30469b61f901cd6404f5d3a5cc14.tar.gz |
MySQL: Ignore unique indexes when removing implicit indexes
MySQL will implicitly create indexes when using foreign keys. Alembic
attempts to remove those implicit indexes so they don't appear as
removes when comparing metadata.
However, unique indexes with the same name as a column are considered
as possibly implicitly created causing alembic to emit a spurious
'remove_constraint'.
Since MySQL will never implicitly create unique indexes, they can be
safely ignored when removing the implicit indexes.
Fixes #251
Diffstat (limited to 'alembic/ddl/mysql.py')
-rw-r--r-- | alembic/ddl/mysql.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index b93d29f..cb9d634 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -102,6 +102,8 @@ class MySQLImpl(DefaultImpl): # the name of the index may be the column name or it may # be the name of the FK constraint. for col in idx.columns: + if idx.unique: + continue if idx.name == col.name: conn_indexes.remove(idx) removed.add(idx.name) |