Skip to content

Commit

Permalink
Add data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmwangemi committed Jan 17, 2024
1 parent 8509b67 commit 66c628b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class JudgmentAdmin(ImportExportMixin, DocumentAdmin):
CaseNumberAdmin,
JudgmentRelationshipStackedInline,
] + DocumentAdmin.inlines
filter_horizontal = ("judges", "attorneys", "order_outcome")
filter_horizontal = ("judges", "attorneys", "order_outcomes")
list_filter = (*DocumentAdmin.list_filter, "court")
fieldsets = copy.deepcopy(DocumentAdmin.fieldsets)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# Generated by Django 3.2.19 on 2024-01-16 13:40
# Generated by Django 3.2.19 on 2024-01-17 09:20

from django.db import migrations, models


class Migration(migrations.Migration):
def copy_data(apps, schema_editor):
Judgment = apps.get_model("peachjam", "Judgment")

for judgment in Judgment.objects.all().iterator(chunk_size=100):
judgment.order_outcomes.add(judgment.order_outcome)
judgment.save()


class Migration(migrations.Migration):
dependencies = [
("peachjam", "0114_alter_court_country"),
]

operations = [
migrations.RemoveField(
migrations.AddField(
model_name="judgment",
name="order_outcome",
name="order_outcomes",
field=models.ManyToManyField(blank=True, to="peachjam.OrderOutcome"),
),
migrations.AddField(
migrations.RunPython(copy_data),
migrations.RemoveField(
model_name="judgment",
name="order_outcome",
field=models.ManyToManyField(blank=True, to="peachjam.OrderOutcome"),
),
]
2 changes: 1 addition & 1 deletion peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class Judgment(CoreDocument):
attorneys = models.ManyToManyField(
Attorney, blank=True, verbose_name=_("attorneys")
)
order_outcome = models.ManyToManyField(
order_outcomes = models.ManyToManyField(
OrderOutcome,
blank=True,
)
Expand Down

0 comments on commit 66c628b

Please sign in to comment.