36 lines
927 B
Python
36 lines
927 B
Python
# Generated by Django 5.1.5 on 2025-01-29 17:48
|
|
|
|
import django.db.models.deletion
|
|
from django.db import migrations, models
|
|
|
|
from games.models import Session
|
|
|
|
|
|
def connect_session_to_game(apps, schema_editor):
|
|
for session in Session.objects.all():
|
|
game = session.purchase.first_edition.game
|
|
session.game = game
|
|
session.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("games", "0049_alter_game_unique_together"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="session",
|
|
name="game",
|
|
field=models.ForeignKey(
|
|
blank=True,
|
|
default=None,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="sessions",
|
|
to="games.game",
|
|
),
|
|
),
|
|
migrations.RunPython(connect_session_to_game),
|
|
]
|