Remove Edition
This commit is contained in:
@ -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):
|
||||
|
35
games/migrations/0050_session_game.py
Normal file
35
games/migrations/0050_session_game.py
Normal 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),
|
||||
]
|
29
games/migrations/0051_purchase_games.py
Normal file
29
games/migrations/0051_purchase_games.py
Normal 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),
|
||||
]
|
17
games/migrations/0052_remove_purchase_editions.py
Normal file
17
games/migrations/0052_remove_purchase_editions.py
Normal 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',
|
||||
),
|
||||
]
|
16
games/migrations/0053_delete_edition.py
Normal file
16
games/migrations/0053_delete_edition.py
Normal 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',
|
||||
),
|
||||
]
|
17
games/migrations/0054_remove_session_purchase.py
Normal file
17
games/migrations/0054_remove_session_purchase.py
Normal 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',
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user