-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8509b67
commit 66c628b
Showing
3 changed files
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 14 additions & 6 deletions
20
...ge_order_outcome_field_to_many_to_many.py → ...nd_delete_old_order_outcome_field_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters