mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-29 17:28:02 +01:00
feat(db): add role log table to database
This commit is contained in:
29
prisma/migrations/20230303182446_role_logs/migration.sql
Normal file
29
prisma/migrations/20230303182446_role_logs/migration.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "RoleLog" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"modId" TEXT NOT NULL,
|
||||
"roleId" TEXT NOT NULL,
|
||||
"add" BOOLEAN NOT NULL DEFAULT false,
|
||||
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "RoleLog_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Role" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"staff" BOOLEAN NOT NULL,
|
||||
|
||||
CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RoleLog" ADD CONSTRAINT "RoleLog_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RoleLog" ADD CONSTRAINT "RoleLog_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "RoleLog" ADD CONSTRAINT "RoleLog_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -42,6 +42,8 @@ model User {
|
||||
SendPayment Payment[] @relation("sendPayment")
|
||||
RecievePayment Payment[] @relation("recievePayment")
|
||||
LeaveLog LeaveLog[]
|
||||
UserRoleLog RoleLog[] @relation("userRoleLog")
|
||||
ModRoleLog RoleLog[] @relation("modRoleLog")
|
||||
EventLeader Event[] @relation("eventLeader")
|
||||
StatLeader Stat[] @relation("statLeader")
|
||||
OutreachParticipation ParticipantStat[] @relation("participantUser")
|
||||
@@ -129,6 +131,25 @@ model LeaveLog {
|
||||
roles String[]
|
||||
}
|
||||
|
||||
model RoleLog {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation("userRoleLog", fields: [userId], references: [id])
|
||||
userId String
|
||||
mod User @relation("modRoleLog", fields: [modId], references: [id])
|
||||
modId String
|
||||
role Role @relation(fields: [roleId], references: [id])
|
||||
roleId String
|
||||
add Boolean @default(false)
|
||||
time DateTime @default(now())
|
||||
}
|
||||
|
||||
model Role {
|
||||
id String @id
|
||||
name String
|
||||
staff Boolean
|
||||
RoleLog RoleLog[]
|
||||
}
|
||||
|
||||
// Outreach
|
||||
|
||||
model Event {
|
||||
|
||||
Reference in New Issue
Block a user