diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-05 16:22:14 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-05 16:22:14 -0400 |
commit | 1f4d8c61033685d90c344c96222e2f8249ca68e8 (patch) | |
tree | 527f060c7b23227d157fbcafb5b6d5af1910bcd6 /alembic/ddl | |
parent | 0a93da93d011118d9446e0ef7b4d5d80e550adfb (diff) | |
download | alembic-1f4d8c61033685d90c344c96222e2f8249ca68e8.tar.gz |
- Liberalized even more the check for MySQL indexes that shouldn't be
counted in autogenerate as "drops"; this time it's been reported
that an implicitly created index might be named the same as a composite
foreign key constraint, and not the actual columns, so we now skip those
when detected as well. fixes #208
Diffstat (limited to 'alembic/ddl')
-rw-r--r-- | alembic/ddl/mysql.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index 96f42f3..58d5c70 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -78,10 +78,19 @@ class MySQLImpl(DefaultImpl): removed = set() for idx in list(conn_indexes): # MySQL puts implicit indexes on FK columns, even if - # composite and even if MyISAM, so can't check this too easily - if idx.name == idx.columns.keys()[0]: - conn_indexes.remove(idx) - removed.add(idx.name) + # composite and even if MyISAM, so can't check this too easily. + # 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.name == col.name: + conn_indexes.remove(idx) + removed.add(idx.name) + break + for fk in col.foreign_keys: + if fk.name == idx.name: + conn_indexes.remove(idx) + removed.add(idx.name) + break # then remove indexes from the "metadata_indexes" # that we've removed from reflected, otherwise they come out |