mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-15 10:13:15 -05:00
Ensures all existing one to one fields are nulled before altering the field
This commit is contained in:
parent
9188e25dc5
commit
14b6216b49
@ -4,6 +4,17 @@ from django.db import migrations, models
|
|||||||
import django.db.models.deletion
|
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():
|
||||||
|
task.attempted_task = None
|
||||||
|
task.save()
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
@ -12,6 +23,10 @@ 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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user