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
This commit is contained in:
Kirill Zaitsev 2015-06-12 02:51:16 +03:00
parent 2cb5c185ad
commit 508739984d
2 changed files with 8 additions and 8 deletions

View File

@ -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':

View File

@ -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':