Remove Edition
Some checks failed
Django CI/CD / test (push) Failing after 54s
Django CI/CD / build-and-push (push) Has been skipped

This commit is contained in:
2025-01-29 22:05:06 +01:00
parent e571feadef
commit 6bd8271291
29 changed files with 286 additions and 467 deletions

View File

@ -29,12 +29,15 @@ def copy_platform_to_game(apps, schema_editor):
print(
f"Game '{game}' with ID '{game.pk}' missing edition with platform '{e.platform}', creating..."
)
Game.objects.create(
newgame = Game.objects.create(
name=e.name,
sort_name=e.sort_name,
platform=e.platform,
year_released=e.year_released,
)
print(f"Setting edition to a newly created game with id '{newgame.pk}'")
e.game = newgame
e.save()
class Migration(migrations.Migration):

View File

@ -0,0 +1,35 @@
# 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),
]

View File

@ -0,0 +1,29 @@
# 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),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 5.1.5 on 2025-01-29 18:20
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('games', '0051_purchase_games'),
]
operations = [
migrations.RemoveField(
model_name='purchase',
name='editions',
),
]

View File

@ -0,0 +1,16 @@
# Generated by Django 5.1.5 on 2025-01-29 19:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('games', '0052_remove_purchase_editions'),
]
operations = [
migrations.DeleteModel(
name='Edition',
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 5.1.5 on 2025-01-29 19:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('games', '0053_delete_edition'),
]
operations = [
migrations.RemoveField(
model_name='session',
name='purchase',
),
]