Files
breakpilot-core/pitch-deck/migrations/003_pitch_versions.sql
Sharang Parnerkar 1c3cec2c06
Some checks failed
Build pitch-deck / build-and-push (push) Failing after 1m8s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 32s
CI / test-python-voice (push) Successful in 32s
CI / test-bqas (push) Successful in 32s
CI / Deploy (push) Failing after 4s
feat(pitch-deck): full pitch versioning with git-style history (#4)
Full pitch versioning: 12 data tables versioned as JSONB snapshots,
git-style parent chain (draft→commit→fork), per-investor assignment,
side-by-side diff engine, version-aware /api/data + /api/financial-model.

Bug fixes: FM editor [object Object] for JSONB arrays, admin scroll.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 07:37:33 +00:00

37 lines
1.8 KiB
SQL

-- =========================================================
-- Pitch Deck: Version Management (Git-Style History)
-- =========================================================
-- Version metadata: each version points to its parent (git-style DAG)
CREATE TABLE IF NOT EXISTS pitch_versions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
description TEXT,
parent_id UUID REFERENCES pitch_versions(id) ON DELETE SET NULL,
status VARCHAR(20) NOT NULL DEFAULT 'draft'
CHECK (status IN ('draft', 'committed')),
created_by UUID REFERENCES pitch_admins(id) ON DELETE SET NULL,
committed_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_pitch_versions_parent ON pitch_versions(parent_id);
CREATE INDEX IF NOT EXISTS idx_pitch_versions_status ON pitch_versions(status);
-- Version content: one row per data table per version (fully materialized)
-- table_name values: company, team, financials, market, competitors, features,
-- milestones, metrics, funding, products, fm_scenarios, fm_assumptions
CREATE TABLE IF NOT EXISTS pitch_version_data (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
version_id UUID NOT NULL REFERENCES pitch_versions(id) ON DELETE CASCADE,
table_name TEXT NOT NULL,
data JSONB NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_by UUID REFERENCES pitch_admins(id) ON DELETE SET NULL,
UNIQUE(version_id, table_name)
);
CREATE INDEX IF NOT EXISTS idx_pitch_version_data_version ON pitch_version_data(version_id);
-- Per-investor version assignment (NULL = use base tables)
ALTER TABLE pitch_investors
ADD COLUMN IF NOT EXISTS assigned_version_id UUID REFERENCES pitch_versions(id) ON DELETE SET NULL;