From 70a101ca986d6ce743d951989dd02309cb968029 Mon Sep 17 00:00:00 2001 From: Simone Cavalli Date: Fri, 19 Jun 2026 18:59:41 +0200 Subject: [PATCH] feat(20-01): add migration 0009_client_transcripts.sql DDL for client_transcripts table: id (nanoid PK), lead_id/client_id (nullable FKs with ON DELETE CASCADE), title, content (NOT NULL), call_date (date NOT NULL), created_at (timestamptz). Three indexes on lead_id, client_id, call_date DESC. APPLY TO PROD via SSH before pushing schema-dependent code (Plan 20-02/20-03). Co-Authored-By: Claude Sonnet 4.6 --- src/db/migrations/0009_client_transcripts.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/db/migrations/0009_client_transcripts.sql diff --git a/src/db/migrations/0009_client_transcripts.sql b/src/db/migrations/0009_client_transcripts.sql new file mode 100644 index 0000000..2e394e9 --- /dev/null +++ b/src/db/migrations/0009_client_transcripts.sql @@ -0,0 +1,22 @@ +-- Phase 20: Knowledge Base Cliente — tabella transcript datati per lead/cliente +-- Additive only. No drops/truncates (Data Safety LOCKED). +-- Applicare a prod via SSH tunnel PRIMA di pushare il codice dipendente (D-03). + +CREATE TABLE IF NOT EXISTS client_transcripts ( + id text PRIMARY KEY NOT NULL, + lead_id text REFERENCES leads(id) ON DELETE CASCADE, + client_id text REFERENCES clients(id) ON DELETE CASCADE, + title text, + content text NOT NULL, + call_date date NOT NULL, + created_at timestamp with time zone NOT NULL DEFAULT now() +); + +CREATE INDEX IF NOT EXISTS client_transcripts_lead_id_idx + ON client_transcripts (lead_id); + +CREATE INDEX IF NOT EXISTS client_transcripts_client_id_idx + ON client_transcripts (client_id); + +CREATE INDEX IF NOT EXISTS client_transcripts_call_date_idx + ON client_transcripts (call_date DESC);