1 # Generated by Django 4.0.3 on 2022-03-13 17:16
3 from django.db import migrations, models
13 BOULDER_DIFFICULTY_CHOICES = (
34 def forward(app, schema_editor):
35 Pitch = app.get_model('climbing', 'Pitch')
36 Problem = app.get_model('climbing', 'Problem')
40 for i, s in enumerate(SAFETY_CHOICES)
43 difficulty_choices = {
45 for i, d in enumerate(BOULDER_DIFFICULTY_CHOICES)
48 for p in Pitch.objects.all():
49 p.safety = safety_choices[p.safety_old]
52 for p in Problem.objects.all():
53 p.difficulty = difficulty_choices[p.difficulty_old]
54 p.safety = safety[p.safety_old]
57 def backward(app, schema_editor):
58 Pitch = app.get_model('climbing', 'Pitch')
59 Problem = app.get_model('climbing', 'Problem')
61 for p in Pitch.objects.all():
62 p.safety_old = SAFETY_CHOICES[p.safety][0]
65 for p in Problem.objects.all():
66 p.difficulty_old = BOULDER_DIFFICULTY_CHOICES[p.difficulty][0]
67 p.safety_old = SAFETY_CHOICES[p.safety][0]
71 class Migration(migrations.Migration):
74 ('climbing', '0009_rename_safety_pitch_safety_old_and_more'),
81 field=models.IntegerField(choices=[(0, 'G'), (1, 'PG'), (2, 'PG13'), (3, 'R'), (4, 'X')], default=0),
82 preserve_default=False,
87 field=models.IntegerField(choices=[(0, 'V0'), (1, 'V1'), (2, 'V2'), (3, 'V3'), (4, 'V4'), (5, 'V5'), (6, 'V6'), (7, 'V7'), (8, 'V8'), (9, 'V9'), (10, 'V10'), (11, 'V11'), (12, 'V12'), (13, 'V13'), (14, 'V14'), (15, 'V15'), (16, 'V16'), (17, 'V17')], default=0),
88 preserve_default=False,
93 field=models.IntegerField(choices=[(0, 'G'), (1, 'PG'), (2, 'PG13'), (3, 'R'), (4, 'X')], default=0),
94 preserve_default=False,
96 migrations.RunPython(forward, backward),