A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fixes up some issues with the migrations and type mismatches
Trenton H19d4b8596135
diff --git a/src/documents/migrations/1022_paperlesstask.py b/src/documents/migrations/1022_paperlesstask.pyindex 2c22000f4..b89e9bbac 100644--- a/src/documents/migrations/1022_paperlesstask.py+++ b/src/documents/migrations/1022_paperlesstask.py@@ -41,7 +41,7 @@ class Migration(migrations.Migration):null=True,on_delete=django.db.models.deletion.CASCADE,related_name="attempted_task",- # This is a dummy field, AlterField in 1026 will set to correct value+ # This is a dummy field, 1026 will fix up the column# This manual change is required, as django doesn't django doesn't really support# removing an app which has migration deps like thisto="documents.document",diff --git a/src/documents/migrations/1026_remove_paperlesstask_created_and_more.py b/src/documents/migrations/1026_transition_to_celery.pysimilarity index 57%rename from src/documents/migrations/1026_remove_paperlesstask_created_and_more.pyrename to src/documents/migrations/1026_transition_to_celery.pyindex ef7bae0be..ad0665fa2 100644--- a/src/documents/migrations/1026_remove_paperlesstask_created_and_more.py+++ b/src/documents/migrations/1026_transition_to_celery.py@@ -11,8 +11,9 @@ def _attempted_task(apps, schema_editor):task_model = apps.get_model("documents", "PaperlessTask")for task in task_model.objects.all():- task.attempted_task = None- task.save()+ if hasattr(task, "attempted_task"):+ task.attempted_task = None+ task.save()class Migration(migrations.Migration):@@ -23,10 +24,6 @@ class Migration(migrations.Migration):]operations = [- migrations.RunPython(- code=_attempted_task,- reverse_code=migrations.RunPython.noop,- ),migrations.RemoveField(model_name="paperlesstask",name="created",@@ -39,7 +36,21 @@ class Migration(migrations.Migration):model_name="paperlesstask",name="started",),- migrations.AlterField(+ # 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",+ name="attempted_task",+ ),+ # Add the field back, pointing to the correct model+ # This resolves a problem where the temporary change in 1022+ # results in a type mismatch+ migrations.AddField(model_name="paperlesstask",name="attempted_task",field=models.OneToOneField(@@ -50,4 +61,14 @@ class Migration(migrations.Migration):to="django_celery_results.taskresult",),),+ # Drop the django-q tables entirely+ migrations.RunSQL(+ "DROP TABLE IF EXISTS django_q_ormq", reverse_sql=migrations.RunSQL.noop+ ),+ migrations.RunSQL(+ "DROP TABLE IF EXISTS django_q_schedule", reverse_sql=migrations.RunSQL.noop+ ),+ migrations.RunSQL(+ "DROP TABLE IF EXISTS django_q_task", reverse_sql=migrations.RunSQL.noop+ ),]diff --git a/src/documents/migrations/1027_drop_django_q.py b/src/documents/migrations/1027_drop_django_q.pydeleted file mode 100644index 878563cc6..000000000--- a/src/documents/migrations/1027_drop_django_q.py+++ /dev/null@@ -1,24 +0,0 @@-# Generated by Django 4.0.7 on 2022-09-05 21:39--from django.db import migrations---class Migration(migrations.Migration):-- dependencies = [- ("documents", "1026_remove_paperlesstask_created_and_more"),- ]-- # Manual SQL commands to drop the django_q related tables- # if they exist- operations = [- migrations.RunSQL(- "DROP TABLE IF EXISTS django_q_ormq", reverse_sql=migrations.RunSQL.noop- ),- migrations.RunSQL(- "DROP TABLE IF EXISTS django_q_schedule", reverse_sql=migrations.RunSQL.noop- ),- migrations.RunSQL(- "DROP TABLE IF EXISTS django_q_task", reverse_sql=migrations.RunSQL.noop- ),- ]