Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migrations #1735

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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