From: Mike Bayer Date: Fri, 14 Aug 2015 18:44:28 +0000 (-0400) Subject: Add non-model index names to autogen exclude filters X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7ca5a26c982084ed0b4cf036917a64580da6385c;p=openstack-build%2Fneutron-build.git Add non-model index names to autogen exclude filters 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 --- diff --git a/neutron/db/migration/alembic_migrations/env.py b/neutron/db/migration/alembic_migrations/env.py index 9b65f9325..a1faba158 100644 --- a/neutron/db/migration/alembic_migrations/env.py +++ b/neutron/db/migration/alembic_migrations/env.py @@ -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