Skip to content

Commit d8a0659

Browse files
committed
[prisma] updated
1 parent 95a70d0 commit d8a0659

File tree

4 files changed

+10172
-295
lines changed

4 files changed

+10172
-295
lines changed

apps/uni-pusher

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
-- CreateSchema
2+
CREATE SCHEMA IF NOT EXISTS "social-platform";
3+
4+
-- CreateSchema
5+
CREATE SCHEMA IF NOT EXISTS "totem-gpt";
6+
7+
-- CreateEnum
8+
CREATE TYPE "public"."SseStatus" AS ENUM ('preparing', 'running', 'interrupted', 'finished');
9+
10+
-- CreateTable
11+
CREATE TABLE "totem-gpt"."TotemGenRequest" (
12+
"id" TEXT NOT NULL DEFAULT nanoid(7),
13+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
14+
"updatedAt" TIMESTAMP(3) NOT NULL,
15+
"userId" VARCHAR(7) NOT NULL,
16+
"prompt" TEXT NOT NULL,
17+
18+
CONSTRAINT "TotemGenRequest_pkey" PRIMARY KEY ("id")
19+
);
20+
21+
-- CreateTable
22+
CREATE TABLE "totem-gpt"."TotemGenResponse" (
23+
"id" TEXT NOT NULL DEFAULT nanoid(7),
24+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
25+
"updatedAt" TIMESTAMP(3) NOT NULL,
26+
"requestId" TEXT NOT NULL,
27+
"status" "public"."SseStatus" NOT NULL DEFAULT 'preparing',
28+
"stream" TEXT NOT NULL,
29+
30+
CONSTRAINT "TotemGenResponse_pkey" PRIMARY KEY ("id")
31+
);
32+
33+
-- CreateTable
34+
CREATE TABLE "totem-gpt"."TotemGenResponseActions" (
35+
"id" TEXT NOT NULL DEFAULT nanoid(7),
36+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
37+
"updatedAt" TIMESTAMP(3) NOT NULL,
38+
"responseId" TEXT NOT NULL,
39+
"userId" VARCHAR(7) NOT NULL,
40+
"type" TEXT NOT NULL,
41+
"detail" TEXT,
42+
43+
CONSTRAINT "TotemGenResponseActions_pkey" PRIMARY KEY ("id")
44+
);
45+
46+
-- CreateTable
47+
CREATE TABLE "social-platform"."SocialPlatform" (
48+
"id" TEXT NOT NULL,
49+
"title" TEXT NOT NULL,
50+
"description" TEXT NOT NULL,
51+
"icon" TEXT NOT NULL,
52+
53+
CONSTRAINT "SocialPlatform_pkey" PRIMARY KEY ("id")
54+
);
55+
56+
-- CreateTable
57+
CREATE TABLE "social-platform"."SocialPlatformAuth" (
58+
"id" VARCHAR(7) NOT NULL DEFAULT nanoid(7),
59+
"userId" TEXT NOT NULL,
60+
"socialPlatformId" TEXT NOT NULL,
61+
"isLoggedIn" BOOLEAN NOT NULL DEFAULT false,
62+
"options" JSONB,
63+
64+
CONSTRAINT "SocialPlatformAuth_pkey" PRIMARY KEY ("id")
65+
);
66+
67+
-- CreateTable
68+
CREATE TABLE "social-platform"."SocialPlatformEvent" (
69+
"id" TEXT NOT NULL DEFAULT nanoid(7),
70+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
71+
"updatedAt" TIMESTAMP(3) NOT NULL,
72+
"type" TEXT NOT NULL,
73+
"payload" JSONB,
74+
"authId" TEXT NOT NULL,
75+
76+
CONSTRAINT "SocialPlatformEvent_pkey" PRIMARY KEY ("id")
77+
);
78+
79+
-- CreateTable
80+
CREATE TABLE "social-platform"."SocialPlatformPost" (
81+
"id" TEXT NOT NULL DEFAULT nanoid(7),
82+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
83+
"updatedAt" TIMESTAMP(3) NOT NULL,
84+
"authId" TEXT NOT NULL,
85+
"text" TEXT,
86+
"images" JSONB,
87+
"audios" JSONB,
88+
"vidios" JSONB,
89+
"files" JSONB,
90+
"location" JSONB,
91+
"permissions" JSONB,
92+
"publishTime" TIMESTAMP(3),
93+
94+
CONSTRAINT "SocialPlatformPost_pkey" PRIMARY KEY ("id")
95+
);
96+
97+
-- AddForeignKey
98+
ALTER TABLE "totem-gpt"."TotemGenRequest" ADD CONSTRAINT "TotemGenRequest_userId_fkey" FOREIGN KEY ("userId") REFERENCES "customer"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
99+
100+
-- AddForeignKey
101+
ALTER TABLE "totem-gpt"."TotemGenResponse" ADD CONSTRAINT "TotemGenResponse_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "totem-gpt"."TotemGenRequest"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
102+
103+
-- AddForeignKey
104+
ALTER TABLE "totem-gpt"."TotemGenResponseActions" ADD CONSTRAINT "TotemGenResponseActions_responseId_fkey" FOREIGN KEY ("responseId") REFERENCES "totem-gpt"."TotemGenResponse"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
105+
106+
-- AddForeignKey
107+
ALTER TABLE "totem-gpt"."TotemGenResponseActions" ADD CONSTRAINT "TotemGenResponseActions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "customer"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
108+
109+
-- AddForeignKey
110+
ALTER TABLE "social-platform"."SocialPlatformAuth" ADD CONSTRAINT "SocialPlatformAuth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "customer"."User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
111+
112+
-- AddForeignKey
113+
ALTER TABLE "social-platform"."SocialPlatformAuth" ADD CONSTRAINT "SocialPlatformAuth_socialPlatformId_fkey" FOREIGN KEY ("socialPlatformId") REFERENCES "social-platform"."SocialPlatform"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
114+
115+
-- AddForeignKey
116+
ALTER TABLE "social-platform"."SocialPlatformEvent" ADD CONSTRAINT "SocialPlatformEvent_authId_fkey" FOREIGN KEY ("authId") REFERENCES "social-platform"."SocialPlatformAuth"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
117+
118+
-- AddForeignKey
119+
ALTER TABLE "social-platform"."SocialPlatformPost" ADD CONSTRAINT "SocialPlatformPost_authId_fkey" FOREIGN KEY ("authId") REFERENCES "social-platform"."SocialPlatformAuth"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

prisma/schema.prisma

Lines changed: 138 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ datasource db {
3535
3636
extensions = [vector]
3737
38-
schemas = ["public", "auth", "customer", "payment", "llm", "poketto", "wechat", "assistant"]
38+
schemas = ["public", "auth", "customer", "payment", "llm", "poketto", "wechat", "assistant", "social-platform", "totem-gpt"]
3939
}
4040

4141
// -----------------------------------------------------------------------------
@@ -147,12 +147,15 @@ model User {
147147
// 每日需要更新
148148
149149
/// [ModelQuota]
150-
quota Json?
151-
feedbacks Feedback[]
152-
appCategories PokettoAppCategory[]
153-
coupons Coupon[]
154-
evalApps EvalApp[]
155-
evalConvs Conv[]
150+
quota Json?
151+
feedbacks Feedback[]
152+
appCategories PokettoAppCategory[]
153+
coupons Coupon[]
154+
evalApps EvalApp[]
155+
evalConvs Conv[]
156+
SocialPlatformAuth SocialPlatformAuth[]
157+
TotemGPTGenRequest TotemGenRequest[]
158+
TotemGenResponseActions TotemGenResponseActions[]
156159
157160
// maybe we only need one id
158161
@@unique([platformType, platformId], name: "platform")
@@ -976,3 +979,131 @@ model Task {
976979
977980
@@schema("assistant")
978981
}
982+
983+
// -----------------------------------------------------------------------------
984+
// totem-gpt
985+
// -----------------------------------------------------------------------------
986+
model TotemGenRequest {
987+
id String @id @default(dbgenerated("nanoid(7)"))
988+
989+
createdAt DateTime @default(now())
990+
updatedAt DateTime @updatedAt
991+
992+
user User @relation(fields: [userId], references: [id])
993+
userId String @db.VarChar(7)
994+
995+
prompt String
996+
response TotemGenResponse[]
997+
998+
@@schema("totem-gpt")
999+
}
1000+
1001+
enum SseStatus {
1002+
preparing
1003+
running
1004+
interrupted
1005+
finished
1006+
1007+
@@schema("public")
1008+
}
1009+
1010+
model TotemGenResponse {
1011+
id String @id @default(dbgenerated("nanoid(7)"))
1012+
createdAt DateTime @default(now())
1013+
updatedAt DateTime @updatedAt
1014+
1015+
request TotemGenRequest @relation(fields: [requestId], references: [id])
1016+
requestId String
1017+
1018+
status SseStatus @default(preparing)
1019+
stream String
1020+
TotemGenResponseActions TotemGenResponseActions[]
1021+
1022+
@@schema("totem-gpt")
1023+
}
1024+
1025+
model TotemGenResponseActions {
1026+
id String @id @default(dbgenerated("nanoid(7)"))
1027+
createdAt DateTime @default(now())
1028+
updatedAt DateTime @updatedAt
1029+
1030+
response TotemGenResponse @relation(fields: [responseId], references: [id])
1031+
responseId String
1032+
1033+
user User @relation(fields: [userId], references: [id])
1034+
userId String @db.VarChar(7)
1035+
1036+
type String
1037+
detail String?
1038+
1039+
@@schema("totem-gpt")
1040+
}
1041+
1042+
// -----------------------------------------------------------------------------
1043+
// social-platform
1044+
// -----------------------------------------------------------------------------
1045+
1046+
model SocialPlatform {
1047+
id String @id
1048+
title String
1049+
description String
1050+
icon String
1051+
SocialPlatformAuth SocialPlatformAuth[]
1052+
1053+
@@schema("social-platform")
1054+
}
1055+
1056+
model SocialPlatformAuth {
1057+
id String @id @default(dbgenerated("nanoid(7)")) @db.VarChar(7)
1058+
user User @relation(fields: [userId], references: [id])
1059+
userId String
1060+
1061+
socialPlatform SocialPlatform @relation(fields: [socialPlatformId], references: [id])
1062+
socialPlatformId String
1063+
1064+
isLoggedIn Boolean @default(false)
1065+
// cookie, sms, mail ...
1066+
options Json?
1067+
events SocialPlatformEvent[]
1068+
SocialPlatformPost SocialPlatformPost[]
1069+
1070+
@@schema("social-platform")
1071+
}
1072+
1073+
model SocialPlatformEvent {
1074+
id String @id @default(dbgenerated("nanoid(7)"))
1075+
1076+
createdAt DateTime @default(now())
1077+
updatedAt DateTime @updatedAt
1078+
1079+
// login / logout / CRUD / comment ...
1080+
type String
1081+
payload Json?
1082+
1083+
auth SocialPlatformAuth @relation(fields: [authId], references: [id])
1084+
authId String
1085+
1086+
@@schema("social-platform")
1087+
}
1088+
1089+
model SocialPlatformPost {
1090+
id String @id @default(dbgenerated("nanoid(7)"))
1091+
1092+
createdAt DateTime @default(now())
1093+
updatedAt DateTime @updatedAt
1094+
1095+
auth SocialPlatformAuth @relation(fields: [authId], references: [id])
1096+
authId String
1097+
1098+
text String?
1099+
images Json?
1100+
audios Json?
1101+
vidios Json?
1102+
files Json?
1103+
location Json?
1104+
permissions Json?
1105+
1106+
publishTime DateTime?
1107+
1108+
@@schema("social-platform")
1109+
}

0 commit comments

Comments
 (0)