mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fixes up some issues with the migrations and type mismatches
This commit is contained in:
parent
04faa10e3b
commit
19d4b85961
@ -41,7 +41,7 @@ class Migration(migrations.Migration):
|
|||||||
null=True,
|
null=True,
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
related_name="attempted_task",
|
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
|
# This manual change is required, as django doesn't django doesn't really support
|
||||||
# removing an app which has migration deps like this
|
# removing an app which has migration deps like this
|
||||||
to="documents.document",
|
to="documents.document",
|
||||||
|
@ -11,8 +11,9 @@ def _attempted_task(apps, schema_editor):
|
|||||||
task_model = apps.get_model("documents", "PaperlessTask")
|
task_model = apps.get_model("documents", "PaperlessTask")
|
||||||
|
|
||||||
for task in task_model.objects.all():
|
for task in task_model.objects.all():
|
||||||
task.attempted_task = None
|
if hasattr(task, "attempted_task"):
|
||||||
task.save()
|
task.attempted_task = None
|
||||||
|
task.save()
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -23,10 +24,6 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(
|
|
||||||
code=_attempted_task,
|
|
||||||
reverse_code=migrations.RunPython.noop,
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name="paperlesstask",
|
model_name="paperlesstask",
|
||||||
name="created",
|
name="created",
|
||||||
@ -39,7 +36,21 @@ class Migration(migrations.Migration):
|
|||||||
model_name="paperlesstask",
|
model_name="paperlesstask",
|
||||||
name="started",
|
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",
|
model_name="paperlesstask",
|
||||||
name="attempted_task",
|
name="attempted_task",
|
||||||
field=models.OneToOneField(
|
field=models.OneToOneField(
|
||||||
@ -50,4 +61,14 @@ class Migration(migrations.Migration):
|
|||||||
to="django_celery_results.taskresult",
|
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
|
||||||
|
),
|
||||||
]
|
]
|
@ -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
|
|
||||||
),
|
|
||||||
]
|
|
Loading…
x
Reference in New Issue
Block a user