-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1842924 - Update deletion constraints for performancedatumreplica…
…te. (#7744)
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
treeherder/perf/migrations/0050_cascade_perf_datum_deletion_replicate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Generated by Django 3.0.8 on 2020-12-11 14:42 | ||
|
||
from django.db import migrations | ||
|
||
DATUM_REPLICATE_CONSTRAINT_SYMBOL = ( | ||
'performance_datum_re_performance_datum_id_fe2ed518_fk_performan' | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('perf', '0049_performancedatumreplicate'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
# add ON DELETE CASCADE at database level | ||
[ | ||
f'ALTER TABLE performance_datum_replicate ' | ||
f'DROP FOREIGN KEY {DATUM_REPLICATE_CONSTRAINT_SYMBOL};', | ||
f'ALTER TABLE performance_datum_replicate ' | ||
f'ADD CONSTRAINT {DATUM_REPLICATE_CONSTRAINT_SYMBOL} ' | ||
f'FOREIGN KEY (performance_datum_id) REFERENCES performance_datum (ID) ON DELETE CASCADE;', | ||
], | ||
# put back the non-CASCADE foreign key constraint | ||
reverse_sql=[ | ||
f'ALTER TABLE performance_datum_replicate ' | ||
f'DROP FOREIGN KEY {DATUM_REPLICATE_CONSTRAINT_SYMBOL};', | ||
f'ALTER TABLE performance_datum_replicate ' | ||
f'ADD CONSTRAINT {DATUM_REPLICATE_CONSTRAINT_SYMBOL} ' | ||
f'FOREIGN KEY (performance_datum_id) REFERENCES performance_datum (ID);', | ||
], | ||
) | ||
] |