feature: Adds permission system.

This commit is contained in:
Tera << 8 2024-04-19 12:48:40 +00:00
parent be91aafb58
commit 0c279b459f
6 changed files with 122 additions and 8 deletions

View file

@ -0,0 +1,20 @@
/*
Warnings:
- You are about to drop the column `permissionID` on the `Permission` table. All the data in the column will be lost.
- Added the required column `permission` to the `Permission` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Permission" (
"permission" TEXT NOT NULL,
"has" BOOLEAN NOT NULL,
"userID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
CONSTRAINT "Permission_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Permission" ("has", "userID") SELECT "has", "userID" FROM "Permission";
DROP TABLE "Permission";
ALTER TABLE "new_Permission" RENAME TO "Permission";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View file

@ -0,0 +1,21 @@
/*
Warnings:
- The primary key for the `Permission` table will be changed. If it partially fails, the table could be left without primary key constraint.
- Added the required column `id` to the `Permission` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Permission" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"permission" TEXT NOT NULL,
"has" BOOLEAN NOT NULL,
"userID" INTEGER NOT NULL,
CONSTRAINT "Permission_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Permission" ("has", "permission", "userID") SELECT "has", "permission", "userID" FROM "Permission";
DROP TABLE "Permission";
ALTER TABLE "new_Permission" RENAME TO "Permission";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View file

@ -37,11 +37,13 @@ model ForwardRule {
}
model Permission {
permissionID String @unique
id Int @id @default(autoincrement())
permission String
has Boolean
user User @relation(fields: [userID], references: [id])
userID Int @id @default(autoincrement())
userID Int
}
model User {