summaryrefslogtreecommitdiff
path: root/makima/migrations
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-16 17:59:38 +0000
committerGitHub <noreply@github.com>2026-02-16 17:59:38 +0000
commitb3de779d87450033f1e0361144c621a1d5f1dbf8 (patch)
tree7cb84c2f953bf86f1dd3ec8ff305d70810ac55de /makima/migrations
parent7d2079d7c13804766405af8044574bfc93a86897 (diff)
downloadsoryu-b3de779d87450033f1e0361144c621a1d5f1dbf8.tar.gz
soryu-b3de779d87450033f1e0361144c621a1d5f1dbf8.zip
Fix contracts page overflow, remove contract link from orders, add directive name (#65)
* feat: soryu-co/soryu - makima: Add frontend pick-up-orders button and API integration * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: Remove contract link from orders and add directive name to order metadata (frontend) * fix: contracts page overflow - use contained scrolling layout Changed the contracts page to use contained scrolling matching the orders/directives pages, preventing the page from growing beyond viewport height. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve completion_task_id FK violation and duplicate button The completion_task_id column has an FK to tasks(id), but claim_directive_for_completion was being called with a placeholder UUID that did not exist in the tasks table, causing FK constraint violations. Fix: Create the task FIRST via create_task_for_owner, then use the real task.id when calling claim_directive_for_completion. Applied in all three locations: phase_completion Part 1 (idle directives), Part 3 (verification tasks), and trigger_completion_task (manual PR creation). Also removes a duplicate "Pick Up Orders" button in DirectiveDetail.tsx. * fix: restore Order type changes lost during rebase conflict resolution Re-apply changes from the orders-refactor commit that were dropped when resolving rebase conflicts with --ours: - Replace contractId with directiveName in Order interface - Make directiveId required in CreateOrderRequest - Remove contractId from UpdateOrderRequest - Change listOrders parameter from contractId to search - Remove linkOrderToContract function - Simplify convertOrderToStep to single argument --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'makima/migrations')
-rw-r--r--makima/migrations/20260216100000_orders_remove_contract_add_directive_name.sql32
1 files changed, 32 insertions, 0 deletions
diff --git a/makima/migrations/20260216100000_orders_remove_contract_add_directive_name.sql b/makima/migrations/20260216100000_orders_remove_contract_add_directive_name.sql
new file mode 100644
index 0000000..cacd7a7
--- /dev/null
+++ b/makima/migrations/20260216100000_orders_remove_contract_add_directive_name.sql
@@ -0,0 +1,32 @@
+-- Remove contract_id from orders (orders are tied only to directives)
+ALTER TABLE orders DROP COLUMN IF EXISTS contract_id;
+DROP INDEX IF EXISTS idx_orders_contract_id;
+
+-- Add directive_name as a denormalized field for searchability
+ALTER TABLE orders ADD COLUMN IF NOT EXISTS directive_name VARCHAR(500);
+
+-- Make directive_id required for new orders (but keep existing NULLs)
+-- We use a trigger approach to populate directive_name automatically
+CREATE OR REPLACE FUNCTION update_order_directive_name()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF NEW.directive_id IS NOT NULL THEN
+ SELECT title INTO NEW.directive_name FROM directives WHERE id = NEW.directive_id;
+ ELSE
+ NEW.directive_name := NULL;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER trg_order_directive_name
+ BEFORE INSERT OR UPDATE OF directive_id ON orders
+ FOR EACH ROW
+ EXECUTE FUNCTION update_order_directive_name();
+
+-- Backfill directive_name for existing orders
+UPDATE orders o SET directive_name = d.title
+FROM directives d WHERE o.directive_id = d.id;
+
+-- Index for searching by directive_name
+CREATE INDEX IF NOT EXISTS idx_orders_directive_name ON orders(directive_name);