Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
vrigal authored and Archaeopteryx committed Aug 11, 2023
1 parent ca5e8fd commit 2d04b04
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Generated by Django 3.0.8 on 2020-12-11 14:42

from django.db import migrations
from django.conf import settings

DATUM_REPLICATE_CONSTRAINT_SYMBOL = (
'performance_datum_re_performance_datum_id_fe2ed518_fk_performan'
)

if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
DROP_TYPE = 'FOREIGN KEY'
else:
DROP_TYPE = 'CONSTRAINT'


class Migration(migrations.Migration):
dependencies = [
Expand All @@ -17,15 +23,15 @@ class Migration(migrations.Migration):
# add ON DELETE CASCADE at database level
[
f'ALTER TABLE performance_datum_replicate '
f'DROP FOREIGN KEY {DATUM_REPLICATE_CONSTRAINT_SYMBOL};',
f'DROP {DROP_TYPE} {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'DROP {DROP_TYPE} {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);',
Expand Down

0 comments on commit 2d04b04

Please sign in to comment.