-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
91 lines (85 loc) · 4.05 KB
/
Copy pathschema.sql
File metadata and controls
91 lines (85 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
-- The Pitch Practice Database Schema (Simplified)
-- Run this in Supabase SQL Editor to create all tables
-- CreateEnum
CREATE TYPE "PitchMode" AS ENUM ('free_pitch', 'one_minute_challenge', 'qa_practice');
-- CreateTable: Pitch
-- Stores metadata about each pitch recording
CREATE TABLE "Pitch" (
"id" TEXT NOT NULL,
"visitorId" TEXT NOT NULL,
"durationSeconds" DOUBLE PRECISION NOT NULL,
"mode" "PitchMode" NOT NULL,
"videoUrl" TEXT,
"videoPathname" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Pitch_pkey" PRIMARY KEY ("id")
);
-- visitorId is an anonymous identifier (anon_xxx).
-- videoUrl / videoPathname point at the Vercel Blob copy of the recording;
-- the browser also keeps a copy in IndexedDB for fast local playback.
-- Migration for existing deployments:
-- ALTER TABLE "Pitch" ADD COLUMN IF NOT EXISTS "videoUrl" TEXT;
-- ALTER TABLE "Pitch" ADD COLUMN IF NOT EXISTS "videoPathname" TEXT;
-- CreateTable: PitchAnalysis
-- Stores the Interhuman AI analysis results
CREATE TABLE "PitchAnalysis" (
"id" TEXT NOT NULL,
"pitchId" TEXT NOT NULL,
"qualityIndex" INTEGER NOT NULL,
"clarity" INTEGER NOT NULL,
"authority" INTEGER NOT NULL,
"energy" INTEGER NOT NULL,
"rapport" INTEGER NOT NULL,
"learning" INTEGER NOT NULL,
"engagementStatesJson" JSONB NOT NULL,
"signalsJson" JSONB NOT NULL,
"timelineJson" JSONB NOT NULL,
"transcriptText" TEXT,
"contentJson" JSONB,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "PitchAnalysis_pkey" PRIMARY KEY ("id")
);
-- transcriptText / contentJson hold the OpenAI transcript + content score.
-- Migration for existing deployments:
-- ALTER TABLE "PitchAnalysis" ADD COLUMN IF NOT EXISTS "transcriptText" TEXT;
-- ALTER TABLE "PitchAnalysis" ADD COLUMN IF NOT EXISTS "contentJson" JSONB;
CREATE UNIQUE INDEX "PitchAnalysis_pitchId_key" ON "PitchAnalysis"("pitchId");
ALTER TABLE "PitchAnalysis" ADD CONSTRAINT "PitchAnalysis_pitchId_fkey" FOREIGN KEY ("pitchId") REFERENCES "Pitch"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- CreateTable: PitchScore
-- Stores computed scores for the leaderboard
CREATE TABLE "PitchScore" (
"id" TEXT NOT NULL,
"pitchId" TEXT NOT NULL,
"visitorId" TEXT NOT NULL,
"userName" TEXT DEFAULT 'Anonymous Founder',
"mode" "PitchMode",
"compositeScore" INTEGER NOT NULL,
"deliveryScore" INTEGER,
"contentScore" INTEGER,
"hasContentScore" BOOLEAN DEFAULT false,
"percentileRank" DOUBLE PRECISION,
"authorityScore" INTEGER NOT NULL,
"clarityScore" INTEGER NOT NULL,
"energyScore" INTEGER NOT NULL,
"confidenceScore" INTEGER NOT NULL,
"hesitationScore" INTEGER NOT NULL,
"badgesEarned" TEXT[],
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "PitchScore_pkey" PRIMARY KEY ("id")
);
-- compositeScore is the blended overall score (delivery + content).
-- deliveryScore retains the delivery-only number; contentScore is null when
-- transcript scoring was unavailable.
-- Migration for existing deployments:
-- ALTER TABLE "PitchScore" ADD COLUMN IF NOT EXISTS "deliveryScore" INTEGER;
-- ALTER TABLE "PitchScore" ADD COLUMN IF NOT EXISTS "contentScore" INTEGER;
-- ALTER TABLE "PitchScore" ADD COLUMN IF NOT EXISTS "hasContentScore" BOOLEAN DEFAULT false;
CREATE UNIQUE INDEX "PitchScore_pitchId_key" ON "PitchScore"("pitchId");
CREATE INDEX "PitchScore_visitorId_compositeScore_idx" ON "PitchScore"("visitorId", "compositeScore");
CREATE INDEX "PitchScore_createdAt_idx" ON "PitchScore"("createdAt");
CREATE INDEX "PitchScore_mode_compositeScore_idx" ON "PitchScore"("mode", "compositeScore" DESC);
ALTER TABLE "PitchScore" ADD CONSTRAINT "PitchScore_pitchId_fkey" FOREIGN KEY ("pitchId") REFERENCES "Pitch"("id") ON DELETE CASCADE ON UPDATE CASCADE;
GRANT USAGE ON SCHEMA public TO postgres, anon, authenticated, service_role;
GRANT ALL ON ALL TABLES IN SCHEMA public TO postgres, service_role;
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO postgres, service_role;
GRANT ALL ON TYPE "PitchMode" TO postgres, service_role;