diff --git a/neutron/db/migration/__init__.py b/neutron/db/migration/__init__.py index 484aeeaee60..b8d94b22f42 100644 --- a/neutron/db/migration/__init__.py +++ b/neutron/db/migration/__init__.py @@ -165,7 +165,7 @@ def create_foreign_keys(table, foreign_keys): referent_table=fk['referred_table'], local_cols=fk['constrained_columns'], remote_cols=fk['referred_columns'], - ondelete='CASCADE' + ondelete=fk['options'].get('ondelete') ) diff --git a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py b/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py index 322f6b06594..4961514dd62 100644 --- a/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py +++ b/neutron/db/migration/alembic_migrations/versions/liberty/contract/2e5352a0ad4d_add_missing_foreign_keys.py @@ -37,5 +37,8 @@ TABLE_NAME = 'flavorserviceprofilebindings' def upgrade(): inspector = reflection.Inspector.from_engine(op.get_bind()) fk_constraints = inspector.get_foreign_keys(TABLE_NAME) + for fk in fk_constraints: + fk['options']['ondelete'] = 'CASCADE' + migration.remove_foreign_keys(TABLE_NAME, fk_constraints) migration.create_foreign_keys(TABLE_NAME, fk_constraints)