Skip to content

Commit

Permalink
All media objects to be deleted without affecting past decisions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Jun 24, 2024
1 parent bcb9417 commit c9a1fdf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
24 changes: 24 additions & 0 deletions api/api/migrations/0067_loosen_media_obj_in_through_model.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
3 changes: 2 additions & 1 deletion api/api/models/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion api/api/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion api/api/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/latest_migrations/api
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c9a1fdf

Please sign in to comment.