ALTER TYPE "NotificationType" ADD VALUE IF NOT EXISTS 'DOCUMENTS_REQUIRED';
ALTER TYPE "NotificationType" ADD VALUE IF NOT EXISTS 'PAYMENT_REQUIRED';

CREATE TABLE IF NOT EXISTS "carplace_funnel_events" (
  "id" TEXT PRIMARY KEY,
  "eventName" TEXT NOT NULL,
  "companyId" TEXT,
  "companySlug" TEXT NOT NULL,
  "vehicleId" TEXT NOT NULL,
  "renterId" TEXT,
  "sessionId" TEXT,
  "path" TEXT,
  "metadata" JSONB NOT NULL DEFAULT '{}',
  "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS "carplace_funnel_events_eventName_createdAt_idx"
  ON "carplace_funnel_events"("eventName", "createdAt");

CREATE INDEX IF NOT EXISTS "carplace_funnel_events_companyId_createdAt_idx"
  ON "carplace_funnel_events"("companyId", "createdAt");

CREATE INDEX IF NOT EXISTS "carplace_funnel_events_companySlug_createdAt_idx"
  ON "carplace_funnel_events"("companySlug", "createdAt");

CREATE INDEX IF NOT EXISTS "carplace_funnel_events_vehicleId_createdAt_idx"
  ON "carplace_funnel_events"("vehicleId", "createdAt");

CREATE INDEX IF NOT EXISTS "carplace_funnel_events_renterId_createdAt_idx"
  ON "carplace_funnel_events"("renterId", "createdAt");
