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 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 18:59:41 +02:00
parent dc934fb04a
commit 70a101ca98
@@ -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);