summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-12 16:04:58 +0000
committersoryu <soryu@soryu.co>2026-02-12 16:04:58 +0000
commitb94c2aa684e64860f40eabe9db8b669c8ced98d6 (patch)
treec5a104e39e939a6eb95307ba2298957bbfb5d012
parent355f10964c4dbec24a244a00caba5c17ed23fc65 (diff)
downloadsoryu-makima/makima-jp--create-database-migration-for-orders-ta-35c83406.tar.gz
soryu-makima/makima-jp--create-database-migration-for-orders-ta-35c83406.zip
feat: makima.jp: Create database migration for orders tablemakima/makima-jp--create-database-migration-for-orders-ta-35c83406
-rw-r--r--makima/migrations/20260212000000_create_orders.sql43
1 files changed, 43 insertions, 0 deletions
diff --git a/makima/migrations/20260212000000_create_orders.sql b/makima/migrations/20260212000000_create_orders.sql
new file mode 100644
index 0000000..0cf0863
--- /dev/null
+++ b/makima/migrations/20260212000000_create_orders.sql
@@ -0,0 +1,43 @@
+-- Orders: Makima's commands - work items for future features, bugs, and spikes
+-- These can be linked to directives or contracts once work begins
+
+CREATE TABLE orders (
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+ owner_id UUID NOT NULL REFERENCES owners(id) ON DELETE CASCADE,
+ title VARCHAR(500) NOT NULL,
+ description TEXT,
+ order_type VARCHAR(32) NOT NULL DEFAULT 'feature'
+ CHECK (order_type IN ('feature', 'bug', 'spike', 'chore')),
+ status VARCHAR(32) NOT NULL DEFAULT 'backlog'
+ CHECK (status IN ('backlog', 'todo', 'in_progress', 'done', 'archived')),
+ priority VARCHAR(32) NOT NULL DEFAULT 'medium'
+ CHECK (priority IN ('low', 'medium', 'high', 'urgent')),
+ directive_id UUID REFERENCES directives(id) ON DELETE SET NULL,
+ contract_id UUID REFERENCES contracts(id) ON DELETE SET NULL,
+ repository_url VARCHAR(512),
+ version INTEGER NOT NULL DEFAULT 1,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
+);
+
+CREATE INDEX idx_orders_owner_id ON orders(owner_id);
+CREATE INDEX idx_orders_status ON orders(owner_id, status);
+CREATE INDEX idx_orders_directive_id ON orders(directive_id);
+CREATE INDEX idx_orders_contract_id ON orders(contract_id);
+CREATE INDEX idx_orders_created_at ON orders(created_at DESC);
+CREATE INDEX idx_orders_priority ON orders(owner_id, priority);
+
+CREATE TABLE order_labels (
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+ owner_id UUID NOT NULL REFERENCES owners(id) ON DELETE CASCADE,
+ name VARCHAR(100) NOT NULL,
+ color VARCHAR(7) NOT NULL DEFAULT '#75aafc',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ UNIQUE(owner_id, name)
+);
+
+CREATE TABLE order_label_assignments (
+ order_id UUID NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
+ label_id UUID NOT NULL REFERENCES order_labels(id) ON DELETE CASCADE,
+ PRIMARY KEY (order_id, label_id)
+);