From 97467c7a52b6d1a8f9d029d8be15a9844d5122ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 9 Jan 2023 19:05:47 +0100 Subject: [PATCH] Also set duration_manual to zero --- Dockerfile | 2 +- .../migrations/0006_auto_20230109_1904.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/web/tracker/migrations/0006_auto_20230109_1904.py diff --git a/Dockerfile b/Dockerfile index 9607513..66a5efe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN npm install && \ FROM python:3.10.9-alpine -ENV VERSION_NUMBER 0.1.2-8-gb77089f +ENV VERSION_NUMBER 0.1.2-9-g7842d6f ENV PROD 1 RUN apk add \ diff --git a/src/web/tracker/migrations/0006_auto_20230109_1904.py b/src/web/tracker/migrations/0006_auto_20230109_1904.py new file mode 100644 index 0000000..c2facb6 --- /dev/null +++ b/src/web/tracker/migrations/0006_auto_20230109_1904.py @@ -0,0 +1,34 @@ +# Generated by Django 4.1.5 on 2023-01-09 18:04 + +from django.db import migrations +from datetime import timedelta + + +def set_duration_manual_none_to_zero(apps, schema_editor): + Session = apps.get_model("tracker", "Session") + for session in Session.objects.all(): + if session.duration_calculated == None: + session.duration_calculated = timedelta(0) + session.save() + + +def revert_set_duration_manual_none_to_zero(apps, schema_editor): + Session = apps.get_model("tracker", "Session") + for session in Session.objects.all(): + if session.duration_calculated == timedelta(0): + session.duration_calculated = None + session.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("tracker", "0005_auto_20230109_1843"), + ] + + operations = [ + migrations.RunPython( + set_duration_manual_none_to_zero, + revert_set_duration_manual_none_to_zero, + ) + ]