2023-01-09 17:57:22 +00:00
|
|
|
# Generated by Django 4.1.5 on 2023-01-09 17:43
|
|
|
|
|
|
|
|
from datetime import timedelta
|
|
|
|
|
2023-01-15 22:39:52 +00:00
|
|
|
from django.db import migrations
|
|
|
|
|
2023-01-09 17:57:22 +00:00
|
|
|
|
|
|
|
def set_duration_calculated_none_to_zero(apps, schema_editor):
|
2023-01-19 19:35:25 +00:00
|
|
|
Session = apps.get_model("games", "Session")
|
2023-01-09 17:57:22 +00:00
|
|
|
for session in Session.objects.all():
|
|
|
|
if session.duration_calculated == None:
|
|
|
|
session.duration_calculated = timedelta(0)
|
|
|
|
session.save()
|
|
|
|
|
|
|
|
|
|
|
|
def revert_set_duration_calculated_none_to_zero(apps, schema_editor):
|
2023-01-19 19:35:25 +00:00
|
|
|
Session = apps.get_model("games", "Session")
|
2023-01-09 17:57:22 +00:00
|
|
|
for session in Session.objects.all():
|
|
|
|
if session.duration_calculated == timedelta(0):
|
|
|
|
session.duration_calculated = None
|
|
|
|
session.save()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2023-01-19 19:35:25 +00:00
|
|
|
("games", "0004_alter_session_duration_manual"),
|
2023-01-09 17:57:22 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(
|
|
|
|
set_duration_calculated_none_to_zero,
|
|
|
|
revert_set_duration_calculated_none_to_zero,
|
|
|
|
)
|
|
|
|
]
|