diff options
Diffstat (limited to 'makima/migrations/20250107000000_simplify_task_depth.sql')
| -rw-r--r-- | makima/migrations/20250107000000_simplify_task_depth.sql | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/makima/migrations/20250107000000_simplify_task_depth.sql b/makima/migrations/20250107000000_simplify_task_depth.sql new file mode 100644 index 0000000..73e4ba0 --- /dev/null +++ b/makima/migrations/20250107000000_simplify_task_depth.sql @@ -0,0 +1,18 @@ +-- Simplify task hierarchy to only 2 levels: orchestrator (depth 0) and subtasks (depth 1) +-- Subtasks cannot have their own children + +-- First, check for any existing depth-2 tasks and fail if found +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM tasks WHERE depth >= 2) THEN + RAISE EXCEPTION 'Cannot migrate: tasks with depth >= 2 exist. Please flatten or delete these tasks first.'; + END IF; +END $$; + +-- Drop the old constraint +ALTER TABLE tasks DROP CONSTRAINT IF EXISTS tasks_depth_check; + +-- Add new stricter constraint (max depth 1) +ALTER TABLE tasks ADD CONSTRAINT tasks_depth_check CHECK (depth >= 0 AND depth < 2); + +COMMENT ON COLUMN tasks.depth IS 'Task hierarchy depth: 0=orchestrator (top-level), 1=subtask. Maximum depth is 1.'; |
