dashboard: restrict access to organization users
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "AccessLevel" AS ENUM ('read', 'write', 'admin');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "project_access" (
|
||||
"id" TEXT NOT NULL,
|
||||
"project_id" TEXT NOT NULL,
|
||||
"user_id" TEXT NOT NULL,
|
||||
"level" "AccessLevel" NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "project_access_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "project_access" ADD CONSTRAINT "project_access_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `project_access` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The `id` column on the `project_access` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "project_access" DROP CONSTRAINT "project_access_pkey",
|
||||
DROP COLUMN "id",
|
||||
ADD COLUMN "id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
ADD CONSTRAINT "project_access_pkey" PRIMARY KEY ("id");
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `organization_slug` to the `project_access` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "project_access" ADD COLUMN "organization_slug" TEXT NOT NULL;
|
||||
@@ -27,9 +27,30 @@ model Project {
|
||||
EventMeta EventMeta[]
|
||||
Reference Reference[]
|
||||
|
||||
access ProjectAccess[]
|
||||
|
||||
@@map("projects")
|
||||
}
|
||||
|
||||
enum AccessLevel {
|
||||
read
|
||||
write
|
||||
admin
|
||||
}
|
||||
|
||||
model ProjectAccess {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
project_id String
|
||||
project Project @relation(fields: [project_id], references: [id])
|
||||
organization_slug String
|
||||
user_id String
|
||||
level AccessLevel
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@map("project_access")
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String
|
||||
|
||||
Reference in New Issue
Block a user