feat(acls): added backend acls

This commit is contained in:
DecDuck
2025-02-04 13:15:34 +11:00
parent 09fd01d9b5
commit d4dd259b5f
66 changed files with 394 additions and 473 deletions
@@ -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;
@@ -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;
+15
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[]
}
+1 -1
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])
}
+2
View File
@@ -11,6 +11,8 @@ model User {
clients Client[]
notifications Notification[]
collections Collection[]
tokens APIToken[]
}
model Notification {