From 8b17a175c3e7e27b789812eba4e3cd760beadb10 Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Tue, 6 Jan 2026 04:08:11 +0000
Subject: Initial Control system

---
 .../migrations/20250107000000_simplify_task_depth.sql  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 makima/migrations/20250107000000_simplify_task_depth.sql

(limited to 'makima/migrations/20250107000000_simplify_task_depth.sql')

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.';
-- 
cgit v1.2.3

