Some checks failed
CI / go-lint (pull_request) Failing after 13s
CI / python-lint (pull_request) Failing after 13s
CI / nodejs-lint (pull_request) Failing after 8s
CI / test-go-consent (pull_request) Failing after 3s
CI / test-python-voice (pull_request) Failing after 10s
CI / test-bqas (pull_request) Failing after 11s
CI / Deploy (pull_request) Has been skipped
Adds a complete version management system where every piece of pitch data (all 12 tables: company, team, financials, market, competitors, features, milestones, metrics, funding, products, fm_scenarios, fm_assumptions) can be versioned, diffed, and assigned per-investor. Version lifecycle: create draft → edit freely → commit (immutable) → fork to create new draft. Parent chain gives full git-style history. Backend: - Migration 003: pitch_versions, pitch_version_data tables + investor assigned_version_id column - lib/version-helpers.ts: snapshot base tables, copy between versions - lib/version-diff.ts: per-table row+field diffing engine - 7 new API routes: versions CRUD, commit, fork, per-table data GET/PUT, diff endpoint - /api/data + /api/financial-model: version-aware loading (check investor's assigned_version_id, serve version data or fall back to base tables) - Investor PATCH: accepts assigned_version_id (validates committed) Frontend: - /pitch-admin/versions: list with status badges, fork/commit/delete - /pitch-admin/versions/new: create from base tables or fork existing - /pitch-admin/versions/[id]: 12-tab JSON editor (one per data table) with save-per-table, commit button, fork button - /pitch-admin/versions/[id]/diff/[otherId]: side-by-side diff view with added/removed/changed highlighting per field - Investors list: version column showing assigned version name - Investor detail: version selector dropdown (committed versions only) - AdminShell: Versions nav item added Bug fixes: - FM editor: [object Object] for JSONB array values → JSON.stringify - Admin pages not scrollable → h-screen + overflow-hidden on shell, min-h-0 on flex column Also includes migration 000 for fresh installs (pitch data tables). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.8 KiB
SQL
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;
|