Initialize clean CSR inventory repository
This commit is contained in:
63
inventory/migrations/0010_workflow_integrity.py
Normal file
63
inventory/migrations/0010_workflow_integrity.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# Generated by Django 5.2.17 on 2026-09-26 11:04
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("inventory", "0009_split_device_specifications"),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="devicetask",
|
||||
index=models.Index(
|
||||
fields=["state", "due_date"], name="inventory_d_state_bfd57d_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="devicetask",
|
||||
index=models.Index(
|
||||
fields=["device", "state"], name="inventory_d_device__f5a9da_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="workflowevent",
|
||||
index=models.Index(
|
||||
fields=["device", "-created_at"], name="inventory_w_device__f6b3a5_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="device",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(
|
||||
(
|
||||
"stage__in",
|
||||
["INTAKE", "INSPECTION", "REPAIR", "STORAGE", "ISSUED"],
|
||||
)
|
||||
),
|
||||
name="valid_device_stage",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="devicetask",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(("state__in", ["OPEN", "DONE"])),
|
||||
name="valid_device_task_state",
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="devicetask",
|
||||
constraint=models.CheckConstraint(
|
||||
condition=models.Q(
|
||||
models.Q(("completed_at__isnull", True), ("state", "OPEN")),
|
||||
models.Q(("completed_at__isnull", False), ("state", "DONE")),
|
||||
_connector="OR",
|
||||
),
|
||||
name="device_task_completion_matches_state",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user