Skip to content

Commit

Permalink
fix: migrations (#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos authored Sep 27, 2024
1 parent bb7e7a2 commit 559525a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions game/migrations/0001_squashed_0025_levels_ordering_pt1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,7 @@ def create_level71():
level59.save()

episode9 = Episode(
pk=9,
name="Blockly Brain Teasers",
first_level=level68,
r_branchiness=0.5,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions game/migrations/0100_reorder_python_levels.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -69,15 +70,21 @@ 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()
)
)


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()
)
)


Expand Down

0 comments on commit 559525a

Please sign in to comment.