Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,597 @@
|
||||
-- Migration: remove self-hosted AI (LLM-Gateway/RAG/Chatbot/AI-Cost/Embeddings) + Legacy-PromptFlow-Engine
|
||||
-- KI->MCP-Pivot, siehe docs/ARCHITECTURE-DECISIONS.md AD-26. Forward-only.
|
||||
-- Rollback/Inverse-SQL als Kommentarblock am Ende (DoD-28).
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TenantChatbotAccess" DROP CONSTRAINT "TenantChatbotAccess_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TenantChatbotAccess" DROP CONSTRAINT "TenantChatbotAccess_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Chat" DROP CONSTRAINT "Chat_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Chat" DROP CONSTRAINT "Chat_ownerUserId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Chat" DROP CONSTRAINT "Chat_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ChatMessage" DROP CONSTRAINT "ChatMessage_chatId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ChatMessagePart" DROP CONSTRAINT "ChatMessagePart_messageId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "GeneratedObject" DROP CONSTRAINT "GeneratedObject_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "GeneratedObject" DROP CONSTRAINT "GeneratedObject_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "GeneratedObject" DROP CONSTRAINT "GeneratedObject_chatId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "AICostEvent" DROP CONSTRAINT "AICostEvent_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TenantAICostSummary" DROP CONSTRAINT "TenantAICostSummary_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowGroupTemplate" DROP CONSTRAINT "PromptFlowGroupTemplate_promptFlowGroupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowGroupEntity" DROP CONSTRAINT "PromptFlowGroupEntity_entityId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowGroupEntity" DROP CONSTRAINT "PromptFlowGroupEntity_promptFlowGroupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlow" DROP CONSTRAINT "PromptFlow_inputEntityId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlow" DROP CONSTRAINT "PromptFlow_promptFlowGroupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowInputVariable" DROP CONSTRAINT "PromptFlowInputVariable_promptFlowId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptTemplate" DROP CONSTRAINT "PromptTemplate_flowId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowOutput" DROP CONSTRAINT "PromptFlowOutput_promptFlowId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowOutput" DROP CONSTRAINT "PromptFlowOutput_entityId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" DROP CONSTRAINT "PromptFlowOutputMapping_promptFlowOutputId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" DROP CONSTRAINT "PromptFlowOutputMapping_promptTemplateId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" DROP CONSTRAINT "PromptFlowOutputMapping_propertyId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" DROP CONSTRAINT "PromptFlowExecution_flowId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" DROP CONSTRAINT "PromptFlowExecution_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" DROP CONSTRAINT "PromptFlowExecution_tenantId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptTemplateResult" DROP CONSTRAINT "PromptTemplateResult_flowExecutionId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "PromptTemplateResult" DROP CONSTRAINT "PromptTemplateResult_templateId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Tenant" DROP COLUMN "aiCostLastAlertedPeriod",
|
||||
DROP COLUMN "aiCostLastAlertedThreshold",
|
||||
DROP COLUMN "aiQuotaOverrideJson",
|
||||
DROP COLUMN "chatbotAccessMode",
|
||||
DROP COLUMN "chatbotDefaultCapabilities";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Entity" DROP COLUMN "promptFlowGroupId";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "TenantChatbotAccess";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "Chat";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "ChatMessage";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "ChatMessagePart";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "GeneratedObject";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "AICostEvent";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "TenantAICostSummary";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowGroup";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowGroupTemplate";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowGroupEntity";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlow";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowInputVariable";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptTemplate";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowOutput";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowOutputMapping";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptFlowExecution";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "PromptTemplateResult";
|
||||
|
||||
|
||||
|
||||
-- =================== INVERSE / ROLLBACK (nur Referenz, NICHT ausgefuehrt) ===================
|
||||
/*
|
||||
-- AlterTable
|
||||
ALTER TABLE "Tenant" ADD COLUMN "aiCostLastAlertedPeriod" TEXT,
|
||||
ADD COLUMN "aiCostLastAlertedThreshold" INTEGER,
|
||||
ADD COLUMN "aiQuotaOverrideJson" JSONB,
|
||||
ADD COLUMN "chatbotAccessMode" TEXT NOT NULL DEFAULT 'all_members',
|
||||
ADD COLUMN "chatbotDefaultCapabilities" TEXT[] DEFAULT ARRAY[]::TEXT[];
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Entity" ADD COLUMN "promptFlowGroupId" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TenantChatbotAccess" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenantId" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"capabilityScopes" TEXT[],
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "TenantChatbotAccess_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Chat" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"type" TEXT NOT NULL DEFAULT 'tenant',
|
||||
"tenantId" TEXT,
|
||||
"scope" TEXT NOT NULL DEFAULT 'workspace',
|
||||
"ownerUserId" TEXT,
|
||||
"userId" TEXT,
|
||||
"sessionId" TEXT,
|
||||
"title" TEXT,
|
||||
"lastMessageAt" TIMESTAMP(3),
|
||||
"archivedAt" TIMESTAMP(3),
|
||||
"metadata" JSONB,
|
||||
|
||||
CONSTRAINT "Chat_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ChatMessage" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"chatId" TEXT NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "ChatMessage_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ChatMessagePart" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"messageId" TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL DEFAULT 0,
|
||||
"type" TEXT NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "ChatMessagePart_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "GeneratedObject" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"tenantId" TEXT,
|
||||
"userId" TEXT NOT NULL,
|
||||
"object" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"model" TEXT NOT NULL,
|
||||
"userPrompt" TEXT NOT NULL,
|
||||
"fullPrompt" TEXT NOT NULL,
|
||||
"currentData" TEXT DEFAULT '{}',
|
||||
"generatedData" TEXT NOT NULL DEFAULT '{}',
|
||||
"timeMs" INTEGER NOT NULL DEFAULT 0,
|
||||
"metadata" TEXT NOT NULL DEFAULT '{}',
|
||||
"status" TEXT NOT NULL DEFAULT 'pending',
|
||||
"error" TEXT,
|
||||
"description" TEXT,
|
||||
"inputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"inputTokensCost" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"outputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"outputTokensCost" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"totalTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"costInCents" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"chatId" TEXT,
|
||||
|
||||
CONSTRAINT "GeneratedObject_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AICostEvent" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenantId" TEXT,
|
||||
"userId" TEXT,
|
||||
"capability" TEXT NOT NULL,
|
||||
"provider" TEXT NOT NULL,
|
||||
"model" TEXT NOT NULL,
|
||||
"inputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"outputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"totalTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"costCents" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"pricingVersion" TEXT,
|
||||
"requestId" TEXT NOT NULL,
|
||||
"isOverage" BOOLEAN NOT NULL DEFAULT false,
|
||||
"markedUpCostCents" DOUBLE PRECISION,
|
||||
"stripeReportedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "AICostEvent_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TenantAICostSummary" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenantId" TEXT NOT NULL,
|
||||
"periodStart" TIMESTAMP(3) NOT NULL,
|
||||
"periodEnd" TIMESTAMP(3) NOT NULL,
|
||||
"totalCostCents" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"totalInputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"totalOutputTokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"eventCount" INTEGER NOT NULL DEFAULT 0,
|
||||
"breakdown" JSONB NOT NULL DEFAULT '{}',
|
||||
"computedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "TenantAICostSummary_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowGroup" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"order" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowGroup_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowGroupTemplate" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"order" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"promptFlowGroupId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowGroupTemplate_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowGroupEntity" (
|
||||
"entityId" TEXT NOT NULL,
|
||||
"promptFlowGroupId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowGroupEntity_pkey" PRIMARY KEY ("entityId","promptFlowGroupId")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlow" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"model" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
"actionTitle" TEXT,
|
||||
"executionType" TEXT NOT NULL DEFAULT 'sequential',
|
||||
"promptFlowGroupId" TEXT,
|
||||
"stream" BOOLEAN NOT NULL DEFAULT false,
|
||||
"public" BOOLEAN NOT NULL DEFAULT true,
|
||||
"inputEntityId" TEXT,
|
||||
|
||||
CONSTRAINT "PromptFlow_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowInputVariable" (
|
||||
"id" TEXT NOT NULL,
|
||||
"promptFlowId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"isRequired" BOOLEAN NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowInputVariable_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptTemplate" (
|
||||
"id" TEXT NOT NULL,
|
||||
"flowId" TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"template" TEXT NOT NULL,
|
||||
"temperature" DECIMAL(65,30) NOT NULL,
|
||||
"maxTokens" INTEGER,
|
||||
"generations" INTEGER,
|
||||
|
||||
CONSTRAINT "PromptTemplate_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowOutput" (
|
||||
"id" TEXT NOT NULL,
|
||||
"promptFlowId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"entityId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowOutput_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowOutputMapping" (
|
||||
"id" TEXT NOT NULL,
|
||||
"promptFlowOutputId" TEXT NOT NULL,
|
||||
"promptTemplateId" TEXT NOT NULL,
|
||||
"propertyId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PromptFlowOutputMapping_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptFlowExecution" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"flowId" TEXT NOT NULL,
|
||||
"model" TEXT,
|
||||
"userId" TEXT,
|
||||
"tenantId" TEXT,
|
||||
"status" TEXT NOT NULL,
|
||||
"error" TEXT,
|
||||
"startedAt" TIMESTAMP(3),
|
||||
"completedAt" TIMESTAMP(3),
|
||||
"duration" INTEGER,
|
||||
|
||||
CONSTRAINT "PromptFlowExecution_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PromptTemplateResult" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"flowExecutionId" TEXT NOT NULL,
|
||||
"templateId" TEXT,
|
||||
"order" INTEGER NOT NULL,
|
||||
"status" TEXT NOT NULL,
|
||||
"prompt" TEXT NOT NULL,
|
||||
"response" TEXT,
|
||||
"error" TEXT,
|
||||
"startedAt" TIMESTAMP(3),
|
||||
"completedAt" TIMESTAMP(3),
|
||||
|
||||
CONSTRAINT "PromptTemplateResult_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TenantChatbotAccess_tenantId_idx" ON "TenantChatbotAccess"("tenantId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "TenantChatbotAccess_tenantId_userId_key" ON "TenantChatbotAccess"("tenantId", "userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_type_idx" ON "Chat"("type");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_tenantId_userId_idx" ON "Chat"("tenantId", "userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "chat_tenant_user_type_created_at_idx" ON "Chat"("tenantId", "userId", "type", "createdAt" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "chat_type_user_created_at_idx" ON "Chat"("type", "userId", "createdAt" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "chat_workspace_owner_scope_updated_at" ON "Chat"("tenantId", "ownerUserId", "scope", "updatedAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "chat_workspace_scope_last_message_at" ON "Chat"("tenantId", "scope", "lastMessageAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_sessionId_idx" ON "Chat"("sessionId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_createdAt_idx" ON "Chat"("createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ChatMessage_chatId_idx" ON "ChatMessage"("chatId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ChatMessage_createdAt_idx" ON "ChatMessage"("createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ChatMessagePart_messageId_order_idx" ON "ChatMessagePart"("messageId", "order");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_userId_idx" ON "GeneratedObject"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_tenantId_createdAt_idx" ON "GeneratedObject"("tenantId", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_object_idx" ON "GeneratedObject"("object");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_status_idx" ON "GeneratedObject"("status");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_createdAt_idx" ON "GeneratedObject"("createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "GeneratedObject_chatId_idx" ON "GeneratedObject"("chatId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "AICostEvent_requestId_key" ON "AICostEvent"("requestId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AICostEvent_tenantId_createdAt_idx" ON "AICostEvent"("tenantId", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AICostEvent_tenantId_capability_createdAt_idx" ON "AICostEvent"("tenantId", "capability", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AICostEvent_provider_model_createdAt_idx" ON "AICostEvent"("provider", "model", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AICostEvent_createdAt_idx" ON "AICostEvent"("createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "AICostEvent_tenantId_isOverage_stripeReportedAt_idx" ON "AICostEvent"("tenantId", "isOverage", "stripeReportedAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ai_cost_event_unreported_overage_created_at_idx" ON "AICostEvent"("tenantId", "isOverage", "stripeReportedAt", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TenantAICostSummary_tenantId_periodEnd_idx" ON "TenantAICostSummary"("tenantId", "periodEnd");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TenantAICostSummary_periodStart_idx" ON "TenantAICostSummary"("periodStart");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "TenantAICostSummary_tenantId_periodStart_key" ON "TenantAICostSummary"("tenantId", "periodStart");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "PromptFlowOutputMapping_promptFlowOutputId_promptTemplateId_key" ON "PromptFlowOutputMapping"("promptFlowOutputId", "promptTemplateId", "propertyId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TenantChatbotAccess" ADD CONSTRAINT "TenantChatbotAccess_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TenantChatbotAccess" ADD CONSTRAINT "TenantChatbotAccess_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Chat" ADD CONSTRAINT "Chat_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Chat" ADD CONSTRAINT "Chat_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Chat" ADD CONSTRAINT "Chat_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ChatMessage" ADD CONSTRAINT "ChatMessage_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ChatMessagePart" ADD CONSTRAINT "ChatMessagePart_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "ChatMessage"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GeneratedObject" ADD CONSTRAINT "GeneratedObject_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GeneratedObject" ADD CONSTRAINT "GeneratedObject_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GeneratedObject" ADD CONSTRAINT "GeneratedObject_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "AICostEvent" ADD CONSTRAINT "AICostEvent_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TenantAICostSummary" ADD CONSTRAINT "TenantAICostSummary_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowGroupTemplate" ADD CONSTRAINT "PromptFlowGroupTemplate_promptFlowGroupId_fkey" FOREIGN KEY ("promptFlowGroupId") REFERENCES "PromptFlowGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowGroupEntity" ADD CONSTRAINT "PromptFlowGroupEntity_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "Entity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowGroupEntity" ADD CONSTRAINT "PromptFlowGroupEntity_promptFlowGroupId_fkey" FOREIGN KEY ("promptFlowGroupId") REFERENCES "PromptFlowGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlow" ADD CONSTRAINT "PromptFlow_inputEntityId_fkey" FOREIGN KEY ("inputEntityId") REFERENCES "Entity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlow" ADD CONSTRAINT "PromptFlow_promptFlowGroupId_fkey" FOREIGN KEY ("promptFlowGroupId") REFERENCES "PromptFlowGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowInputVariable" ADD CONSTRAINT "PromptFlowInputVariable_promptFlowId_fkey" FOREIGN KEY ("promptFlowId") REFERENCES "PromptFlow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptTemplate" ADD CONSTRAINT "PromptTemplate_flowId_fkey" FOREIGN KEY ("flowId") REFERENCES "PromptFlow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowOutput" ADD CONSTRAINT "PromptFlowOutput_promptFlowId_fkey" FOREIGN KEY ("promptFlowId") REFERENCES "PromptFlow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowOutput" ADD CONSTRAINT "PromptFlowOutput_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "Entity"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" ADD CONSTRAINT "PromptFlowOutputMapping_promptFlowOutputId_fkey" FOREIGN KEY ("promptFlowOutputId") REFERENCES "PromptFlowOutput"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" ADD CONSTRAINT "PromptFlowOutputMapping_promptTemplateId_fkey" FOREIGN KEY ("promptTemplateId") REFERENCES "PromptTemplate"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowOutputMapping" ADD CONSTRAINT "PromptFlowOutputMapping_propertyId_fkey" FOREIGN KEY ("propertyId") REFERENCES "Property"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" ADD CONSTRAINT "PromptFlowExecution_flowId_fkey" FOREIGN KEY ("flowId") REFERENCES "PromptFlow"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" ADD CONSTRAINT "PromptFlowExecution_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptFlowExecution" ADD CONSTRAINT "PromptFlowExecution_tenantId_fkey" FOREIGN KEY ("tenantId") REFERENCES "Tenant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptTemplateResult" ADD CONSTRAINT "PromptTemplateResult_flowExecutionId_fkey" FOREIGN KEY ("flowExecutionId") REFERENCES "PromptFlowExecution"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PromptTemplateResult" ADD CONSTRAINT "PromptTemplateResult_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "PromptTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
*/
|
||||
Reference in new issue
Block a user