From 508739984da3740d8d2fe1acb84ebce88688c7f1 Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Fri, 12 Jun 2015 02:51:16 +0300 Subject: [PATCH] Migrations: ignore mysql fk cheks for any mysql driver Before mysql migrations disabled foreign key checks only for mysql+mysqldb engine. Currently mysql+pymysql is preferred engine. This change disables FK checks for any mysql engine available. Change-Id: I536480559260c4be11b6e615c0df8f012798be9d Closes-Bug: #1464271 --- .../versions/004_change_package_desc_type.py | 8 ++++---- .../versions/008_fix_unique_constraints.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py b/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py index 9b47bec3f..208b40770 100644 --- a/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py +++ b/murano/db/migration/alembic_migrations/versions/004_change_package_desc_type.py @@ -35,7 +35,7 @@ MYSQL_CHARSET = 'utf8' def upgrade(): engine = op.get_bind() - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=0') if engine.dialect.dialect_description == 'postgresql+psycopg2': @@ -78,7 +78,7 @@ def upgrade(): 'package', ['fully_qualified_name']) - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=1') if engine.dialect.dialect_description == 'postgresql+psycopg2': @@ -103,7 +103,7 @@ def upgrade(): def downgrade(): engine = op.get_bind() - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=0') if engine.dialect.dialect_description == 'postgresql+psycopg2': @@ -146,7 +146,7 @@ def downgrade(): 'package', ['fully_qualified_name']) - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=1') if engine.dialect.dialect_description == 'postgresql+psycopg2': diff --git a/murano/db/migration/alembic_migrations/versions/008_fix_unique_constraints.py b/murano/db/migration/alembic_migrations/versions/008_fix_unique_constraints.py index 1a090e448..d7f94edb5 100644 --- a/murano/db/migration/alembic_migrations/versions/008_fix_unique_constraints.py +++ b/murano/db/migration/alembic_migrations/versions/008_fix_unique_constraints.py @@ -38,7 +38,7 @@ MYSQL_CHARSET = 'utf8' def upgrade(): engine = op.get_bind() - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=0') if engine.dialect.dialect_description == 'postgresql+psycopg2': op.drop_constraint('package_to_tag_package_id_fkey', @@ -89,7 +89,7 @@ def upgrade(): mysql_charset=MYSQL_CHARSET ) - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=1') if engine.dialect.dialect_description == 'postgresql+psycopg2': @@ -121,7 +121,7 @@ def downgrade(): op.drop_index('ix_class_definition_name', table_name='class_definition') engine = op.get_bind() - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=0') if engine.dialect.dialect_description == 'postgresql+psycopg2': op.drop_constraint('package_to_tag_package_id_fkey', @@ -174,7 +174,7 @@ def downgrade(): mysql_charset=MYSQL_CHARSET ) - if engine.dialect.dialect_description == 'mysql+mysqldb': + if engine.dialect.dialect_description.startswith('mysql'): engine.execute('SET FOREIGN_KEY_CHECKS=1') if engine.dialect.dialect_description == 'postgresql+psycopg2':