feat(acls): added backend acls

This commit is contained in:
DecDuck
2025-02-04 13:15:34 +11:00
parent 256fbd6afa
commit 090d2e6586
70 changed files with 397 additions and 474 deletions

View File

@ -0,0 +1,15 @@
-- CreateEnum
CREATE TYPE "APITokenMode" AS ENUM ('User', 'System');
-- CreateTable
CREATE TABLE "APIToken" (
"token" TEXT NOT NULL,
"mode" "APITokenMode" NOT NULL,
"userId" TEXT,
"acls" TEXT[],
CONSTRAINT "APIToken_pkey" PRIMARY KEY ("token")
);
-- AddForeignKey
ALTER TABLE "APIToken" ADD CONSTRAINT "APIToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "CollectionEntry" DROP CONSTRAINT "CollectionEntry_gameId_fkey";
-- AddForeignKey
ALTER TABLE "CollectionEntry" ADD CONSTRAINT "CollectionEntry_gameId_fkey" FOREIGN KEY ("gameId") REFERENCES "Game"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -21,3 +21,18 @@ model Invitation {
email String?
expires DateTime
}
enum APITokenMode {
User
System
}
model APIToken {
token String @id @default(uuid())
mode APITokenMode
userId String?
user User? @relation(fields: [userId], references: [id])
acls String[]
}

View File

@ -14,7 +14,7 @@ model CollectionEntry {
collection Collection @relation(fields: [collectionId], references: [id], onDelete: Cascade)
gameId String
game Game @relation(fields: [gameId], references: [id])
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
@@id([collectionId, gameId])
}

View File

@ -12,6 +12,8 @@ model User {
notifications Notification[]
collections Collection[]
news News[]
tokens APIToken[]
}
model Notification {