This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user