2024-04-02 10:04:54 +03:00
|
|
|
-- CreateTable
|
|
|
|
CREATE TABLE "ai_sessions" (
|
2024-04-10 14:15:25 +03:00
|
|
|
"id" VARCHAR(36) NOT NULL,
|
2024-04-02 10:04:54 +03:00
|
|
|
"user_id" VARCHAR NOT NULL,
|
|
|
|
"workspace_id" VARCHAR NOT NULL,
|
|
|
|
"doc_id" VARCHAR NOT NULL,
|
|
|
|
"prompt_name" VARCHAR NOT NULL,
|
|
|
|
"action" BOOLEAN NOT NULL,
|
2024-04-10 14:15:25 +03:00
|
|
|
"flavor" VARCHAR NOT NULL,
|
2024-04-02 10:04:54 +03:00
|
|
|
"model" VARCHAR NOT NULL,
|
|
|
|
"messages" JSON NOT NULL,
|
|
|
|
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
"updated_at" TIMESTAMPTZ(6) NOT NULL,
|
|
|
|
|
|
|
|
CONSTRAINT "ai_sessions_pkey" PRIMARY KEY ("id")
|
|
|
|
);
|
|
|
|
|
|
|
|
-- AddForeignKey
|
|
|
|
ALTER TABLE "ai_sessions" ADD CONSTRAINT "ai_sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
-- AddForeignKey
|
|
|
|
ALTER TABLE "ai_sessions" ADD CONSTRAINT "ai_sessions_workspace_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
-- AddForeignKey
|
|
|
|
ALTER TABLE "ai_sessions" ADD CONSTRAINT "ai_sessions_doc_id_workspace_id_fkey" FOREIGN KEY ("doc_id", "workspace_id") REFERENCES "snapshots"("guid", "workspace_id") ON DELETE CASCADE ON UPDATE CASCADE;
|