mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-06-22 15:27:28 -05:00
Fix: add negation to scheduled wf migration
This commit is contained in:
parent
cc5ba71f06
commit
ba20dabfa4
@ -4,6 +4,13 @@ from django.db import migrations
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
def invert_existing_offset_values(apps, schema_editor):
|
||||||
|
WorkflowTrigger = apps.get_model("documents", "WorkflowTrigger")
|
||||||
|
WorkflowTrigger.objects.filter(
|
||||||
|
type=4,
|
||||||
|
).update(schedule_offset_days=models.F("schedule_offset_days") * -1)
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("documents", "1065_workflowaction_assign_custom_fields_values"),
|
("documents", "1065_workflowaction_assign_custom_fields_values"),
|
||||||
@ -19,4 +26,8 @@ class Migration(migrations.Migration):
|
|||||||
verbose_name="schedule offset days",
|
verbose_name="schedule offset days",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
code=invert_existing_offset_values,
|
||||||
|
reverse_code=migrations.RunPython.noop,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
19
src/documents/tests/test_migration_invert_scheduled.py
Normal file
19
src/documents/tests/test_migration_invert_scheduled.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from documents.tests.utils import DirectoriesMixin
|
||||||
|
from documents.tests.utils import TestMigrations
|
||||||
|
|
||||||
|
|
||||||
|
class TestMigrateScheduledWorkflowTrigger(DirectoriesMixin, TestMigrations):
|
||||||
|
migrate_from = "1065_workflowaction_assign_custom_fields_values"
|
||||||
|
migrate_to = "1066_alter_workflowtrigger_schedule_offset_days"
|
||||||
|
|
||||||
|
def setUpBeforeMigration(self, apps):
|
||||||
|
WorkflowTrigger = apps.get_model("documents", "WorkflowTrigger")
|
||||||
|
WorkflowTrigger.objects.create(
|
||||||
|
type=4,
|
||||||
|
schedule_offset_days=5,
|
||||||
|
)
|
||||||
|
|
||||||
|
def testTriggerMigrated(self):
|
||||||
|
WorkflowTrigger = self.apps.get_model("documents", "WorkflowTrigger")
|
||||||
|
trigger = WorkflowTrigger.objects.get(id=1)
|
||||||
|
self.assertEqual(trigger.schedule_offset_days, -5)
|
Loading…
x
Reference in New Issue
Block a user