feat: add new role permissions for app creation and backup access, update related models and utilities

This commit is contained in:
biersoeckli
2025-03-07 15:51:44 +00:00
parent cd1da58106
commit 48575b2e45
26 changed files with 237 additions and 78 deletions

View File

@@ -0,0 +1,18 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Role" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"description" TEXT,
"canCreateNewApps" BOOLEAN NOT NULL DEFAULT false,
"canAccessBackups" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_Role" ("createdAt", "description", "id", "name", "updatedAt") SELECT "createdAt", "description", "id", "name", "updatedAt" FROM "Role";
DROP TABLE "Role";
ALTER TABLE "new_Role" RENAME TO "Role";
CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -118,14 +118,13 @@ model Authenticator {
// *** FROM HERE CUSTOM CLASSES
model Role {
id String @id @default(uuid())
name String @unique
description String?
id String @id @default(uuid())
name String @unique
description String?
canCreateNewApps Boolean @default(false)
canAccessBackups Boolean @default(false)
// A Role can be assigned to multiple users
users User[]
// A Role defines permissions on apps via the join model below
users User[]
roleAppPermissions RoleAppPermission[]
createdAt DateTime @default(now())