mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-29 17:28:02 +01:00
feat(database): add fun logging to database
This commit is contained in:
29
prisma/migrations/20230307144946_fun_logs/migration.sql
Normal file
29
prisma/migrations/20230307144946_fun_logs/migration.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "FunLog" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"sendUserId" TEXT NOT NULL,
|
||||
"receiveUserId" TEXT,
|
||||
"typeId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "FunLog_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "FunType" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "FunType_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "FunType_name_key" ON "FunType"("name");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "FunLog" ADD CONSTRAINT "FunLog_sendUserId_fkey" FOREIGN KEY ("sendUserId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "FunLog" ADD CONSTRAINT "FunLog_receiveUserId_fkey" FOREIGN KEY ("receiveUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "FunLog" ADD CONSTRAINT "FunLog_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "FunType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -45,6 +45,8 @@ model User {
|
||||
LeaveLog LeaveLog[]
|
||||
UserRoleLog RoleLog[] @relation("userRoleLog")
|
||||
ModRoleLog RoleLog[] @relation("modRoleLog")
|
||||
FunLogSender FunLog[] @relation("sendFunLog")
|
||||
FunLogReciever FunLog[] @relation("receiveFunLog")
|
||||
EventLeader Event[] @relation("eventLeader")
|
||||
StatLeader Stat[] @relation("statLeader")
|
||||
OutreachParticipation ParticipantStat[] @relation("participantUser")
|
||||
@@ -160,6 +162,22 @@ model Role {
|
||||
RoleLog RoleLog[]
|
||||
}
|
||||
|
||||
model FunLog {
|
||||
id Int @id @default(autoincrement())
|
||||
sendUser User @relation("sendFunLog", fields: [sendUserId], references: [id])
|
||||
sendUserId String
|
||||
receiveUser User? @relation("receiveFunLog", fields: [receiveUserId], references: [id])
|
||||
receiveUserId String?
|
||||
type FunType @relation(fields: [typeId], references: [id])
|
||||
typeId Int
|
||||
}
|
||||
|
||||
model FunType {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
FunLog FunLog[]
|
||||
}
|
||||
|
||||
// Outreach
|
||||
|
||||
model Event {
|
||||
|
||||
Reference in New Issue
Block a user