purchases can now refer to multiple editions
allows purchases to be for more than one game
This commit is contained in:
18
games/migrations/0042_purchase_editions_temp.py
Normal file
18
games/migrations/0042_purchase_editions_temp.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.3 on 2025-01-07 20:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('games', '0041_purchase_converted_currency_purchase_converted_price_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='purchase',
|
||||
name='editions_temp',
|
||||
field=models.ManyToManyField(blank=True, related_name='temp_purchases', to='games.edition'),
|
||||
),
|
||||
]
|
27
games/migrations/0043_auto_20250107_2117.py
Normal file
27
games/migrations/0043_auto_20250107_2117.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.1.3 on 2025-01-07 20:17
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_edition_to_editions_temp(apps, schema_editor):
|
||||
Purchase = apps.get_model("games", "Purchase")
|
||||
for purchase in Purchase.objects.all():
|
||||
if purchase.edition:
|
||||
print(
|
||||
f"Migrating Purchase {purchase.id} with Edition {purchase.edition.id}"
|
||||
)
|
||||
purchase.editions_temp.add(purchase.edition)
|
||||
print(purchase.editions_temp.all())
|
||||
purchase.save()
|
||||
else:
|
||||
print(f"No edition found for Purchase {purchase.id}")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("games", "0042_purchase_editions_temp"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_edition_to_editions_temp),
|
||||
]
|
18
games/migrations/0044_auto_20250107_2132.py
Normal file
18
games/migrations/0044_auto_20250107_2132.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.3 on 2025-01-07 20:32
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("games", "0043_auto_20250107_2117"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(model_name="purchase", name="edition"),
|
||||
migrations.RenameField(
|
||||
model_name="purchase",
|
||||
old_name="editions_temp",
|
||||
new_name="editions",
|
||||
),
|
||||
]
|
18
games/migrations/0045_alter_purchase_editions.py
Normal file
18
games/migrations/0045_alter_purchase_editions.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.3 on 2025-01-07 20:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('games', '0044_auto_20250107_2132'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='purchase',
|
||||
name='editions',
|
||||
field=models.ManyToManyField(blank=True, related_name='purchases', to='games.edition'),
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user