From da30d8868885530812a55918560fccdfb79dc3e9 Mon Sep 17 00:00:00 2001 From: chyoo Date: Thu, 9 Jul 2026 09:13:01 +0900 Subject: [PATCH] admin appPermissions --- .../migration.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 prisma/migrations/20260709011000_add_admin_roles/migration.sql diff --git a/prisma/migrations/20260709011000_add_admin_roles/migration.sql b/prisma/migrations/20260709011000_add_admin_roles/migration.sql new file mode 100644 index 0000000..180fce8 --- /dev/null +++ b/prisma/migrations/20260709011000_add_admin_roles/migration.sql @@ -0,0 +1,32 @@ +DO $$ +BEGIN + CREATE TYPE "AdminRole" AS ENUM ('OWNER', 'ADMIN', 'OPERATOR', 'VIEWER'); +EXCEPTION + WHEN duplicate_object THEN NULL; +END $$; + +CREATE TABLE IF NOT EXISTS "admin_roles" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "code" "AdminRole" NOT NULL, + "name" TEXT NOT NULL, + "description" TEXT, + "sort_order" INTEGER NOT NULL DEFAULT 0, + "is_active" BOOLEAN NOT NULL DEFAULT true, + "created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "admin_roles_pkey" PRIMARY KEY ("id") +); + +CREATE UNIQUE INDEX IF NOT EXISTS "admin_roles_code_key" + ON "admin_roles"("code"); + +CREATE INDEX IF NOT EXISTS "admin_roles_is_active_sort_order_idx" + ON "admin_roles"("is_active", "sort_order"); + +INSERT INTO "admin_roles" ("code", "name", "description", "sort_order", "is_active") +VALUES + ('OWNER', 'OWNER', '전체 관리자 권한', 1, true), + ('ADMIN', 'ADMIN', '관리자 권한', 2, true), + ('VIEWER', 'VIEWER', '조회 권한', 3, true) +ON CONFLICT ("code") DO NOTHING;