From f19acd400cc5bbe1fe51c004c50ee90d704240d8 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 29 Jan 2026 02:56:44 +0000 Subject: Fix contract type selection --- .../20260130000000_create_contract_templates.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 makima/migrations/20260130000000_create_contract_templates.sql (limited to 'makima/migrations/20260130000000_create_contract_templates.sql') diff --git a/makima/migrations/20260130000000_create_contract_templates.sql b/makima/migrations/20260130000000_create_contract_templates.sql new file mode 100644 index 0000000..17598e2 --- /dev/null +++ b/makima/migrations/20260130000000_create_contract_templates.sql @@ -0,0 +1,19 @@ +-- Create contract_type_templates table for user-defined contract templates +CREATE TABLE contract_type_templates ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + owner_id UUID NOT NULL REFERENCES owners(id) ON DELETE CASCADE, + name VARCHAR(255) NOT NULL, + description TEXT, + phases JSONB NOT NULL, -- [{id, name, order}] + default_phase VARCHAR(64) NOT NULL, + deliverables JSONB, -- {phase_id: [{id, name, priority}]} + version INTEGER NOT NULL DEFAULT 1, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + CONSTRAINT unique_template_name_per_owner UNIQUE (owner_id, name) +); + +CREATE INDEX idx_contract_type_templates_owner_id ON contract_type_templates(owner_id); + +-- Add phase_config column to contracts (stores copied template config at creation time) +ALTER TABLE contracts ADD COLUMN IF NOT EXISTS phase_config JSONB; -- cgit v1.2.3