From 035b71108bf08904ffa49945897daf539758825d Mon Sep 17 00:00:00 2001 From: admin-valentin Date: Sat, 1 Aug 2026 21:24:19 +0000 Subject: [PATCH] feat(CC-064): add contracts, obligations, pipeline_deals migration --- drizzle/0011_contracts_pipeline.sql | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 drizzle/0011_contracts_pipeline.sql diff --git a/drizzle/0011_contracts_pipeline.sql b/drizzle/0011_contracts_pipeline.sql new file mode 100644 index 0000000..1488558 --- /dev/null +++ b/drizzle/0011_contracts_pipeline.sql @@ -0,0 +1,61 @@ +-- CEO OS: Contracts, Obligations, Pipeline Deals +-- Migration 0011_contracts_pipeline + +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "contracts" ( + "id" uuid DEFAULT gen_random_uuid() PRIMARY KEY NOT NULL, + "tenant_id" uuid NOT NULL, + "workspace_id" uuid, + "organization_id" uuid, + "title" text NOT NULL, + "contract_type" text NOT NULL DEFAULT 'other', + "status" text NOT NULL DEFAULT 'draft', + "parties" text[] DEFAULT '{}' NOT NULL, + "start_date" date, + "end_date" date, + "value_minor_units" bigint, + "currency" text DEFAULT 'RON', + "notes" text, + "tags" text[] DEFAULT '{}' NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "deleted_at" timestamp +); + +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "obligations" ( + "id" uuid DEFAULT gen_random_uuid() PRIMARY KEY NOT NULL, + "tenant_id" uuid NOT NULL, + "workspace_id" uuid, + "title" text NOT NULL, + "description" text, + "category" text NOT NULL DEFAULT 'contractual', + "status" text NOT NULL DEFAULT 'pending', + "due_date" date, + "owner" text, + "contract_id" uuid, + "evidence_url" text, + "risk_level" text NOT NULL DEFAULT 'medium', + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL +); + +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "pipeline_deals" ( + "id" uuid DEFAULT gen_random_uuid() PRIMARY KEY NOT NULL, + "tenant_id" uuid NOT NULL, + "workspace_id" uuid, + "organization_id" uuid, + "contact_id" uuid, + "title" text NOT NULL, + "stage" text NOT NULL DEFAULT 'identified', + "value_minor_units" bigint, + "currency" text DEFAULT 'RON', + "probability" integer DEFAULT 50, + "expected_close_date" date, + "notes" text, + "tags" text[] DEFAULT '{}' NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "deleted_at" timestamp +);