From 388e5b56de7a24f558126ba043001039d383b822 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Sun, 22 Nov 2020 11:41:13 +0100 Subject: [PATCH] reversible migrations. --- .../migrations/1000_update_paperless_all.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/documents/migrations/1000_update_paperless_all.py b/src/documents/migrations/1000_update_paperless_all.py index 5e5b475a3..dc6313dd8 100644 --- a/src/documents/migrations/1000_update_paperless_all.py +++ b/src/documents/migrations/1000_update_paperless_all.py @@ -1,4 +1,6 @@ # Generated by Django 3.1.3 on 2020-11-07 12:35 +import uuid + from django.db import migrations, models import django.db.models.deletion @@ -20,6 +22,14 @@ def make_index(apps, schema_editor): print(" --> Cannot create document index.") +def logs_set_default_group(apps, schema_editor): + Log = apps.get_model('documents', 'Log') + for log in Log.objects.all(): + if log.group is None: + log.group = uuid.uuid4() + log.save() + + class Migration(migrations.Migration): dependencies = [ @@ -85,6 +95,10 @@ class Migration(migrations.Migration): name='group', field=models.UUIDField(blank=True, null=True), ), + migrations.RunPython( + code=django.db.migrations.operations.special.RunPython.noop, + reverse_code=logs_set_default_group + ), migrations.RunPython( code=make_index, reverse_code=django.db.migrations.operations.special.RunPython.noop,