]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add non-model index names to autogen exclude filters
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Aug 2015 18:44:28 +0000 (14:44 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Sep 2015 21:23:04 +0000 (17:23 -0400)
The SQLAlchemy MySQL dialect generates implicit indexes
in the less-common case of an integer column within a composite
primary key where autoincrement is not set to False.
Add a rule to ignore these indexes when performing
autogenerate against a target database.

Change-Id: I49abb3f7ad9731cde046fa2862cdb9ec16c3aeb3
Partially-Implements: blueprint online-schema-migrations

neutron/db/migration/alembic_migrations/env.py

index 9b65f9325ff35bb47b84f26fd4c7ef69e837dae4..a1faba158c3fee7bb237d661d76b515c80924647 100644 (file)
@@ -59,9 +59,13 @@ def set_mysql_engine():
                     model_base.BASEV2.__table_args__['mysql_engine'])
 
 
-def include_object(object, name, type_, reflected, compare_to):
+def include_object(object_, name, type_, reflected, compare_to):
     if type_ == 'table' and name in external.TABLES:
         return False
+    elif type_ == 'index' and reflected and name.startswith("idx_autoinc_"):
+        # skip indexes created by SQLAlchemy autoincrement=True
+        # on composite PK integer columns
+        return False
     else:
         return True