Enhance Prisma schema and documentation for dashboard features
- Added new models for DashboardAccessRule and DashboardAuditLog to the Prisma schema, improving access control and logging capabilities. - Updated GuildSettings model to include timezone support. - Revised PHASE-TRACKING.md to reflect the completion of Phase 5 and outline upcoming Phase 6 features, including dashboard layout and settings framework. - Exported new phase 6 features in shared index for better modularity.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "GuildSettings" ADD COLUMN "timezone" TEXT NOT NULL DEFAULT 'Europe/Berlin';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "DashboardAccessRule" (
|
||||
"id" TEXT NOT NULL,
|
||||
"guildId" TEXT NOT NULL,
|
||||
"roleId" TEXT NOT NULL,
|
||||
"modules" JSONB NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "DashboardAccessRule_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "DashboardAuditLog" (
|
||||
"id" TEXT NOT NULL,
|
||||
"guildId" TEXT,
|
||||
"actorUserId" TEXT NOT NULL,
|
||||
"action" TEXT NOT NULL,
|
||||
"path" TEXT,
|
||||
"before" JSONB,
|
||||
"after" JSONB,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "DashboardAuditLog_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "DashboardAccessRule_guildId_idx" ON "DashboardAccessRule"("guildId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DashboardAccessRule_guildId_roleId_key" ON "DashboardAccessRule"("guildId", "roleId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "DashboardAuditLog_guildId_createdAt_idx" ON "DashboardAuditLog"("guildId", "createdAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "DashboardAuditLog_actorUserId_createdAt_idx" ON "DashboardAuditLog"("actorUserId", "createdAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DashboardAccessRule" ADD CONSTRAINT "DashboardAccessRule_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DashboardAuditLog" ADD CONSTRAINT "DashboardAuditLog_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -51,16 +51,47 @@ model Guild {
|
||||
socialFeeds SocialFeed[]
|
||||
scheduledMessages ScheduledMessage[]
|
||||
guildBackups GuildBackup[]
|
||||
dashboardAccessRules DashboardAccessRule[]
|
||||
dashboardAuditLogs DashboardAuditLog[]
|
||||
}
|
||||
|
||||
model GuildSettings {
|
||||
id String @id @default(cuid())
|
||||
guildId String @unique
|
||||
locale String @default("de")
|
||||
timezone String @default("Europe/Berlin")
|
||||
moderationEnabled Boolean @default(true)
|
||||
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model DashboardAccessRule {
|
||||
id String @id @default(cuid())
|
||||
guildId String
|
||||
roleId String
|
||||
modules Json
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([guildId, roleId])
|
||||
@@index([guildId])
|
||||
}
|
||||
|
||||
model DashboardAuditLog {
|
||||
id String @id @default(cuid())
|
||||
guildId String?
|
||||
actorUserId String
|
||||
action String
|
||||
path String?
|
||||
before Json?
|
||||
after Json?
|
||||
createdAt DateTime @default(now())
|
||||
guild Guild? @relation(fields: [guildId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([guildId, createdAt])
|
||||
@@index([actorUserId, createdAt])
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
Reference in New Issue
Block a user