Skip to content

Commit 3e7b599

Browse files
committed
Added data migration to the database migration
1 parent e993411 commit 3e7b599

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/program/migrations/0106_event_video_streaming_and_more.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
from django.db import migrations, models
44

5+
def update_streaming(apps, schema_editor):
6+
# We can't import the models directly as it may be a newer
7+
# version than this migration expects. We use the historical version.
8+
Event = apps.get_model("program", "Event")
9+
EventProposal = apps.get_model("program", "EventProposal")
10+
11+
Event.objects.filter(video_recording=True).update(video_streaming=True)
12+
Event.objects.filter(video_recording=False).update(video_streaming=False)
13+
EventProposal.objects.filter(allow_video_recording=False).update(allow_video_streaming=False)
14+
EventProposal.objects.filter(allow_video_recording=True).update(allow_video_streaming=True)
515

616
class Migration(migrations.Migration):
717

@@ -20,4 +30,5 @@ class Migration(migrations.Migration):
2030
name='allow_video_streaming',
2131
field=models.BooleanField(default=False, help_text='Uncheck if you do not want the event streamed (only if recording is unchecked!).'),
2232
),
33+
migrations.RunPython(update_streaming),
2334
]

0 commit comments

Comments
 (0)