Fixes force to set ondelete=CASCADE in create_foreign_keys()
The create_foreign_keys method there forces any foreign keys that created to have ondelete='CASCADE', no matter whether the foreign_keys parameter passed to the method had that option set. if the wrapper method remove_fks_from_table() is used to preserve the state of foreign keys during a database migration, any foreign keys on the table "perserved" this way will have cascading delete added to them. Change-Id: I04bdc863d67e2228f34a05f588c2e9f562918114 Closes-Bug: #1550027
This commit is contained in:
parent
412012de59
commit
5ca8d0152a
@ -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')
|
||||
)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user