summaryrefslogtreecommitdiff
path: root/tests/test_autogen_indexes.py
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes@erdfelt.com>2014-12-04 09:42:46 -0800
committerJohannes Erdfelt <johannes@erdfelt.com>2014-12-04 09:55:07 -0800
commit22667c19df7e30469b61f901cd6404f5d3a5cc14 (patch)
treec6f7597b89045d827fd0a8eeae3c7afa71965b38 /tests/test_autogen_indexes.py
parent6d5155de3491b9c52c673de5d07920872cdca808 (diff)
downloadalembic-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 'tests/test_autogen_indexes.py')
-rw-r--r--tests/test_autogen_indexes.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_autogen_indexes.py b/tests/test_autogen_indexes.py
index ad839c8..e2d9b4e 100644
--- a/tests/test_autogen_indexes.py
+++ b/tests/test_autogen_indexes.py
@@ -586,6 +586,25 @@ class MySQLUniqueIndexTest(AutogenerateUniqueIndexTest):
else:
assert False, "unexpected success"
+ def test_unique_index_foreign_key(self):
+ m1 = MetaData()
+ m2 = MetaData()
+
+ Table('unq_idx', m1,
+ Column('id', Integer, primary_key=True),
+ Column('x', String(20)),
+ Index('x', 'x', unique=True)
+ )
+
+ Table('unq_idx', m2,
+ Column('id', Integer, primary_key=True),
+ Column('x', String(20)),
+ Index('x', 'x', unique=True)
+ )
+
+ diffs = self._fixture(m1, m2)
+ eq_(diffs, [])
+
class NoUqReflectionIndexTest(NoUqReflection, AutogenerateUniqueIndexTest):
reports_unique_constraints = False