@@ -14,9 +14,24 @@ class Migration(migrations.Migration):
...
@@ -14,9 +14,24 @@ class Migration(migrations.Migration):
('tmssapp','0001_initial'),
('tmssapp','0001_initial'),
]
]
# Start SubTask id with 2 000 000 to avoid overlap with 'old' (test/production) OTDB
operations=[migrations.RunSQL('ALTER SEQUENCE tmssapp_SubTask_id_seq RESTART WITH 2000000;'),
operations=[migrations.RunSQL('ALTER SEQUENCE tmssapp_SubTask_id_seq RESTART WITH 2000000;'),# Start SubTask id with 2 000 000 to avoid overlap with 'old' (test/production) OTDB
migrations.RunPython(populate_choices),
migrations.RunPython(populate_choices),# poppulates the "fixed" enums, with amongst others the subtask_states which are used next in the trigger
migrations.RunSQL("CREATE OR REPLACE FUNCTION tmssapp_check_subtask_state_transition() \
RETURNS trigger AS \
$BODY$ \
BEGIN \
IF OLD.state_id='defining' AND NEW.state_id != 'defined' THEN \
RAISE EXCEPTION 'ILLEGAL SUBTASK STATE TRANSITION FROM % TO %', OLD.state_id, NEW.state_id; \
END IF; \
RETURN NEW; \
END; \
$BODY$ \
LANGUAGE plpgsql VOLATILE; \
DROP TRIGGER IF EXISTS tmssapp_trigger_on_check_subtask_state_transition ON tmssapp_SubTask ; \