mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-12 07:42:40 +10:00
feat(acls): added backend acls
This commit is contained in:
15
prisma/migrations/20250204010021_add_tokens/migration.sql
Normal file
15
prisma/migrations/20250204010021_add_tokens/migration.sql
Normal 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;
|
||||
@ -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;
|
||||
@ -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[]
|
||||
}
|
||||
|
||||
@ -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])
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ model User {
|
||||
notifications Notification[]
|
||||
collections Collection[]
|
||||
news News[]
|
||||
|
||||
tokens APIToken[]
|
||||
}
|
||||
|
||||
model Notification {
|
||||
|
||||
Reference in New Issue
Block a user