CREATE TABLE IF NOT EXISTS "ClientPerformanceEvent" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "userId" uuid REFERENCES "User"("id") ON DELETE SET NULL, "chatId" uuid REFERENCES "Chat"("id") ON DELETE SET NULL, "projectId" varchar(64), "eventType" varchar(64) NOT NULL, "section" varchar(32) DEFAULT 'unknown' NOT NULL, "action" varchar(64), "path" varchar(256), "durationMs" integer DEFAULT 0 NOT NULL, "blockingDurationMs" integer DEFAULT 0 NOT NULL, "domNodeCount" integer DEFAULT 0 NOT NULL, "visibleImageCount" integer DEFAULT 0 NOT NULL, "loadedImageCount" integer DEFAULT 0 NOT NULL, "viewport" jsonb, "browser" varchar(128), "metadata" jsonb, "requesterIp" varchar(64), "requesterUserAgent" text, "occurredAt" timestamp, "createdAt" timestamp DEFAULT now() NOT NULL ); CREATE INDEX IF NOT EXISTS "ClientPerformanceEvent_createdAt_idx" ON "ClientPerformanceEvent" ("createdAt" DESC); CREATE INDEX IF NOT EXISTS "ClientPerformanceEvent_section_createdAt_idx" ON "ClientPerformanceEvent" ("section", "createdAt" DESC); CREATE INDEX IF NOT EXISTS "ClientPerformanceEvent_userId_createdAt_idx" ON "ClientPerformanceEvent" ("userId", "createdAt" DESC); CREATE INDEX IF NOT EXISTS "ClientPerformanceEvent_projectId_createdAt_idx" ON "ClientPerformanceEvent" ("projectId", "createdAt" DESC);