]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fixes migration error if some tasks are defined already 1648/head
authorTrenton H <holmes.trenton@gmail.com>
Tue, 4 Oct 2022 14:56:40 +0000 (07:56 -0700)
committerTrenton H <holmes.trenton@gmail.com>
Tue, 4 Oct 2022 14:56:40 +0000 (07:56 -0700)
src/documents/migrations/1026_transition_to_celery.py

index ad0665fa2fee7d31d08fb60cb057638733532d96..76c6edf11aea5a9f78f4521830933bf4b0b7bbc8 100644 (file)
@@ -4,18 +4,6 @@ from django.db import migrations, models
 import django.db.models.deletion
 
 
-def _attempted_task(apps, schema_editor):
-    """
-    Remove any existing attempted_task one to one fields.
-    """
-    task_model = apps.get_model("documents", "PaperlessTask")
-
-    for task in task_model.objects.all():
-        if hasattr(task, "attempted_task"):
-            task.attempted_task = None
-            task.save()
-
-
 class Migration(migrations.Migration):
 
     dependencies = [
@@ -36,12 +24,6 @@ class Migration(migrations.Migration):
             model_name="paperlesstask",
             name="started",
         ),
-        # Ensure any existing PaperlessTask.attempted_task are nulled
-        # This ensures nothing is pointing to a django-q model
-        migrations.RunPython(
-            code=_attempted_task,
-            reverse_code=migrations.RunPython.noop,
-        ),
         # Remove the field from the model
         migrations.RemoveField(
             model_name="paperlesstask",
@@ -62,6 +44,7 @@ class Migration(migrations.Migration):
             ),
         ),
         # Drop the django-q tables entirely
+        # Must be done last or there could be references here
         migrations.RunSQL(
             "DROP TABLE IF EXISTS django_q_ormq", reverse_sql=migrations.RunSQL.noop
         ),