mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-24 07:18:18 +08:00
chore: reinit schema
This commit is contained in:
@ -1,33 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Chat" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"ctx" JSONB NOT NULL,
|
||||
|
||||
CONSTRAINT "Chat_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Prompt" (
|
||||
"id" TEXT NOT NULL,
|
||||
"chatId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"q" TEXT NOT NULL,
|
||||
"a" TEXT NOT NULL,
|
||||
"upvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
"downvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "Prompt_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_createdAt_idx" ON "Chat"("createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Prompt_chatId_idx" ON "Prompt"("chatId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Prompt_createdAt_idx" ON "Prompt"("createdAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Prompt" ADD CONSTRAINT "Prompt_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `Prompt` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Prompt" DROP CONSTRAINT "Prompt_chatId_fkey";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "Prompt";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Message" (
|
||||
"id" TEXT NOT NULL,
|
||||
"chatId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"role" TEXT NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
"upvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
"downvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "Message_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Message_chatId_idx" ON "Message"("chatId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Message_createdAt_idx" ON "Message"("createdAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Message" ADD CONSTRAINT "Message_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `model` to the `Chat` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Chat" ADD COLUMN "model" JSONB NOT NULL;
|
@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Message" ADD COLUMN "endUser" TEXT NOT NULL DEFAULT '';
|
35
prisma/migrations/20230502100414_init/migration.sql
Normal file
35
prisma/migrations/20230502100414_init/migration.sql
Normal file
@ -0,0 +1,35 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "chat" (
|
||||
"id" TEXT NOT NULL,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"model" JSONB NOT NULL DEFAULT '{}',
|
||||
"ctx" JSONB NOT NULL DEFAULT '{}',
|
||||
|
||||
CONSTRAINT "chat_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "message" (
|
||||
"id" TEXT NOT NULL,
|
||||
"chat_id" TEXT NOT NULL,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"end_user" TEXT NOT NULL DEFAULT '',
|
||||
"role" TEXT NOT NULL DEFAULT '',
|
||||
"content" TEXT NOT NULL DEFAULT '',
|
||||
"upvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
"downvote" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "message_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "chat_created_at_idx" ON "chat"("created_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "message_chat_id_idx" ON "message"("chat_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "message_created_at_idx" ON "message"("created_at");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "message" ADD CONSTRAINT "message_chat_id_fkey" FOREIGN KEY ("chat_id") REFERENCES "chat"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -11,26 +11,28 @@ datasource db {
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
model Json
|
||||
ctx Json
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
model Json @default("{}")
|
||||
ctx Json @default("{}")
|
||||
messages Message[]
|
||||
|
||||
@@index([createdAt])
|
||||
@@index([createdAt], map: "chat_created_at_idx")
|
||||
@@map("chat")
|
||||
}
|
||||
|
||||
model Message {
|
||||
id String @id @default(uuid())
|
||||
chat Chat @relation(fields: [chatId], references: [id])
|
||||
chatId String
|
||||
createdAt DateTime @default(now())
|
||||
endUser String @default("")
|
||||
role String
|
||||
content String
|
||||
chatId String @map("chat_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
endUser String @default("") @map("end_user")
|
||||
role String @default("")
|
||||
content String @default("")
|
||||
upvote Boolean @default(false)
|
||||
downvote Boolean @default(false)
|
||||
|
||||
@@index([chatId])
|
||||
@@index([createdAt])
|
||||
@@index([chatId], map: "message_chat_id_idx")
|
||||
@@index([createdAt], map: "message_created_at_idx")
|
||||
@@map("message")
|
||||
}
|
||||
|
Reference in New Issue
Block a user