diff --git a/api/api/migrations/0067_loosen_media_obj_in_through_model.py b/api/api/migrations/0067_loosen_media_obj_in_through_model.py new file mode 100644 index 00000000000..b172c747dfd --- /dev/null +++ b/api/api/migrations/0067_loosen_media_obj_in_through_model.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.11 on 2024-06-24 12:42 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0066_rename_contentprovider_to_contentsource'), + ] + + operations = [ + migrations.AlterField( + model_name='audiodecisionthrough', + name='media_obj', + field=models.ForeignKey(db_column='identifier', db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='api.audio', to_field='identifier'), + ), + migrations.AlterField( + model_name='imagedecisionthrough', + name='media_obj', + field=models.ForeignKey(db_column='identifier', db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='api.image', to_field='identifier'), + ), + ] diff --git a/api/api/models/audio.py b/api/api/models/audio.py index c751850e84f..5d36585009f 100644 --- a/api/api/models/audio.py +++ b/api/api/models/audio.py @@ -370,7 +370,8 @@ class AudioDecisionThrough(AbstractMediaDecisionThrough): media_obj = models.ForeignKey( Audio, to_field="identifier", - on_delete=models.CASCADE, + on_delete=models.DO_NOTHING, + db_constraint=False, db_column="identifier", ) decision = models.ForeignKey(AudioDecision, on_delete=models.CASCADE) diff --git a/api/api/models/image.py b/api/api/models/image.py index 2f15dfc62cf..9232fe5c901 100644 --- a/api/api/models/image.py +++ b/api/api/models/image.py @@ -173,7 +173,8 @@ class ImageDecisionThrough(AbstractMediaDecisionThrough): media_obj = models.ForeignKey( Image, to_field="identifier", - on_delete=models.CASCADE, + on_delete=models.DO_NOTHING, + db_constraint=False, db_column="identifier", ) decision = models.ForeignKey(ImageDecision, on_delete=models.CASCADE) diff --git a/api/api/models/media.py b/api/api/models/media.py index 8d98296c3bc..a9f3edca10d 100644 --- a/api/api/models/media.py +++ b/api/api/models/media.py @@ -354,7 +354,8 @@ class AbstractMediaDecisionThrough(models.Model): media_obj = models.ForeignKey( AbstractMedia, to_field="identifier", - on_delete=models.CASCADE, + on_delete=models.DO_NOTHING, + db_constraint=False, db_column="identifier", ) decision = models.ForeignKey(AbstractMediaDecision, on_delete=models.CASCADE) diff --git a/api/latest_migrations/api b/api/latest_migrations/api index 2f6c01764f5..924c953d164 100644 --- a/api/latest_migrations/api +++ b/api/latest_migrations/api @@ -2,4 +2,4 @@ # If you have a merge conflict in this file, it means you need to run: # manage.py makemigrations --merge # in order to resolve the conflict between migrations. -0066_contentsource_delete_contentprovider +0067_do_nothing_in_through_model_media_obj