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: Fix migration 81 #1419

Merged
merged 3 commits into from
Feb 15, 2023
Merged
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
17 changes: 13 additions & 4 deletions game/migrations/0081_first_12_levels_no_algo_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
class Migration(migrations.Migration):
def populate_disable_algorithm_score(apps, schema_editor):
Level = apps.get_model("game", "Level")
official_levels = Level.objects.filter(default=True)
for i in range(1, 13):
l = Level.objects.get(name=str(i))
l.disable_algorithm_score = True
l.save()
level = official_levels.get(name=str(i))
level.disable_algorithm_score = True
level.save()

def unpopulate_disable_algorithm_score(apps, schema_editor):
Level = apps.get_model("game", "Level")
official_levels = Level.objects.filter(default=True)
for i in range(1, 13):
level = official_levels.get(name=str(i))
level.disable_algorithm_score = False
level.save()

dependencies = [
("game", "0080_level_disable_algorithm_score"),
]

operations = [
migrations.RunPython(populate_disable_algorithm_score),
migrations.RunPython(populate_disable_algorithm_score, reverse_code=unpopulate_disable_algorithm_score),
]