81 lines
2.8 KiB
SQL
81 lines
2.8 KiB
SQL
-- AlterTable
|
|
ALTER TABLE "EntityRelationship" ADD COLUMN "cascade" BOOLEAN NOT NULL DEFAULT false;
|
|
|
|
-- 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',
|
|
|
|
CONSTRAINT "PromptFlow_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,
|
|
|
|
CONSTRAINT "PromptTemplate_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,
|
|
"userId" TEXT,
|
|
"tenantId" TEXT,
|
|
"status" TEXT NOT NULL,
|
|
"error" TEXT,
|
|
"startedAt" TIMESTAMP(3),
|
|
"completedAt" TIMESTAMP(3),
|
|
|
|
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 NOT NULL,
|
|
"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")
|
|
);
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "PromptTemplate" ADD CONSTRAINT "PromptTemplate_flowId_fkey" FOREIGN KEY ("flowId") REFERENCES "PromptFlow"("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 CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "PromptTemplateResult" ADD CONSTRAINT "PromptTemplateResult_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "PromptTemplate"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|