From 559525a10f942ba5df9fae352bf2c8dd29496b0a Mon Sep 17 00:00:00 2001 From: Stefan Kairinos Date: Fri, 27 Sep 2024 15:48:19 +0100 Subject: [PATCH] fix: migrations (#1735) --- .../0001_squashed_0025_levels_ordering_pt1.py | 3 +++ game/migrations/0100_reorder_python_levels.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/game/migrations/0001_squashed_0025_levels_ordering_pt1.py b/game/migrations/0001_squashed_0025_levels_ordering_pt1.py index 73b6ac302..78ff3ba8c 100644 --- a/game/migrations/0001_squashed_0025_levels_ordering_pt1.py +++ b/game/migrations/0001_squashed_0025_levels_ordering_pt1.py @@ -2874,6 +2874,7 @@ def create_level71(): level59.save() episode9 = Episode( + pk=9, name="Blockly Brain Teasers", first_level=level68, r_branchiness=0.5, @@ -3555,6 +3556,7 @@ def add_levels_80_to_107(apps, schema_editor): count += 1 blocklyAndPythonEpisode = Episode( + pk=10, name="Introduction to Python", first_level=level80, r_branchiness=0.5, @@ -3569,6 +3571,7 @@ def add_levels_80_to_107(apps, schema_editor): blocklyAndPythonEpisode.save() pythonOnlyEpisode = Episode( + pk=11, name="Python", first_level=level100, r_branchiness=0.5, diff --git a/game/migrations/0100_reorder_python_levels.py b/game/migrations/0100_reorder_python_levels.py index c9dd43520..13eb81b79 100644 --- a/game/migrations/0100_reorder_python_levels.py +++ b/game/migrations/0100_reorder_python_levels.py @@ -1,6 +1,7 @@ from django.apps.registry import Apps from django.db import migrations -from django.db.models import F +from django.db.models import F, IntegerField, CharField +from django.db.models.functions import Cast def adjust_python_den_episodes(apps: Apps, *args): @@ -69,7 +70,10 @@ def rename_episode_12_levels(apps: Apps, *args): Level = apps.get_model("game", "Level") Level.objects.filter(default=True, name__in=range(110, 123)).update( - name=F("name") + 891 + name=Cast( + Cast(F("name"), output_field=IntegerField()) + 891, + output_field=CharField() + ) ) @@ -77,7 +81,10 @@ def undo_rename_episode_12_levels(apps: Apps, *args): Level = apps.get_model("game", "Level") Level.objects.filter(default=True, name__in=range(1001, 1014)).update( - name=F("name") - 891 + name=Cast( + Cast(F("name"), output_field=IntegerField()) - 891, + output_field=CharField() + ) )