30 lines
740 B
Python
30 lines
740 B
Python
# Generated by Django 5.1.5 on 2025-01-29 18:03
|
|
|
|
from django.db import migrations, models
|
|
|
|
from games.models import Purchase
|
|
|
|
|
|
def connect_purchase_to_game(apps, schema_editor):
|
|
for purchase in Purchase.objects.all():
|
|
game = purchase.first_edition.game
|
|
purchase.games.add(game)
|
|
purchase.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("games", "0050_session_game"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="purchase",
|
|
name="games",
|
|
field=models.ManyToManyField(
|
|
blank=True, related_name="purchases", to="games.game"
|
|
),
|
|
),
|
|
migrations.RunPython(connect_purchase_to_game),
|
|
]
|