From 745b6f1b794e3d18f0ed42b1d261fc2bbcddb27e Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Thu, 5 Mar 2026 23:16:25 +0000
Subject: WIP: heartbeat checkpoint

---
 .../20260303000000_create_directive_order_groups.sql  | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 makima/migrations/20260303000000_create_directive_order_groups.sql

(limited to 'makima/migrations/20260303000000_create_directive_order_groups.sql')

diff --git a/makima/migrations/20260303000000_create_directive_order_groups.sql b/makima/migrations/20260303000000_create_directive_order_groups.sql
new file mode 100644
index 0000000..8a382e5
--- /dev/null
+++ b/makima/migrations/20260303000000_create_directive_order_groups.sql
@@ -0,0 +1,19 @@
+-- Directive Order Groups (DOGs): Epic-like groupings of orders within a directive.
+CREATE TABLE directive_order_groups (
+    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+    directive_id UUID NOT NULL REFERENCES directives(id) ON DELETE CASCADE,
+    owner_id UUID NOT NULL REFERENCES owners(id) ON DELETE CASCADE,
+    name VARCHAR(500) NOT NULL,
+    description TEXT,
+    status VARCHAR(32) NOT NULL DEFAULT 'open'
+        CHECK (status IN ('open', 'in_progress', 'done', 'archived')),
+    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
+);
+
+CREATE INDEX IF NOT EXISTS idx_dog_directive_id ON directive_order_groups(directive_id);
+CREATE INDEX IF NOT EXISTS idx_dog_owner_id ON directive_order_groups(owner_id);
+
+-- Add optional dog_id to orders
+ALTER TABLE orders ADD COLUMN dog_id UUID REFERENCES directive_order_groups(id) ON DELETE SET NULL;
+CREATE INDEX IF NOT EXISTS idx_orders_dog_id ON orders(dog_id);
-- 
cgit v1.2.3

