Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop FK constraint on media_obj in MediaDecisionThrough, update backfillmoderationdecision command #4530

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/api/management/commands/backfillmoderationdecision.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def handle(self, *args, **options):
MediaReport.objects.bulk_update(reports_chunk, ["decision"])
MediaDecisionThrough.objects.bulk_create(
[
MediaDecisionThrough(media_obj=report.media_obj, decision=decision)
MediaDecisionThrough(
media_obj_id=report.media_obj_id, decision=decision
)
for report, decision in zip(reports_chunk, decisions)
]
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.11 on 2024-06-20 19:51

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.CASCADE, 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.CASCADE, to='api.image', to_field='identifier'),
),
]
1 change: 1 addition & 0 deletions api/api/models/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ class AudioDecisionThrough(AbstractMediaDecisionThrough):
to_field="identifier",
on_delete=models.CASCADE,
stacimc marked this conversation as resolved.
Show resolved Hide resolved
db_column="identifier",
db_constraint=False,
)
decision = models.ForeignKey(AudioDecision, on_delete=models.CASCADE)

Expand Down
1 change: 1 addition & 0 deletions api/api/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class ImageDecisionThrough(AbstractMediaDecisionThrough):
to_field="identifier",
on_delete=models.CASCADE,
db_column="identifier",
db_constraint=False,
)
decision = models.ForeignKey(ImageDecision, on_delete=models.CASCADE)

Expand Down
1 change: 1 addition & 0 deletions api/api/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ class AbstractMediaDecisionThrough(models.Model):
to_field="identifier",
on_delete=models.CASCADE,
db_column="identifier",
db_constraint=False,
)
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_alter_audiodecisionthrough_media_obj_and_more