CREATE TABLE "common_codes" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "group_key" TEXT NOT NULL, "code" TEXT NOT NULL, "label" TEXT NOT NULL, "description" TEXT, "sort_order" INTEGER NOT NULL DEFAULT 0, "is_active" BOOLEAN NOT NULL DEFAULT true, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "common_codes_pkey" PRIMARY KEY ("id") ); CREATE UNIQUE INDEX "common_codes_group_key_code_key" ON "common_codes"("group_key", "code"); CREATE INDEX "common_codes_group_key_is_active_sort_order_idx" ON "common_codes"("group_key", "is_active", "sort_order"); COMMENT ON TABLE "common_codes" IS '공통 코드 마스터. 알림 카테고리 등 화면 표시명과 코드값을 관리한다.'; COMMENT ON COLUMN "common_codes"."id" IS '공통 코드 고유 UUID'; COMMENT ON COLUMN "common_codes"."group_key" IS '공통 코드 그룹 키'; COMMENT ON COLUMN "common_codes"."code" IS '업무에서 사용하는 코드값'; COMMENT ON COLUMN "common_codes"."label" IS '화면에 표시할 코드명'; COMMENT ON COLUMN "common_codes"."description" IS '공통 코드 설명'; COMMENT ON COLUMN "common_codes"."sort_order" IS '같은 그룹 내 표시 순서'; COMMENT ON COLUMN "common_codes"."is_active" IS '공통 코드 사용 여부'; COMMENT ON COLUMN "common_codes"."created_at" IS '공통 코드 생성 일시'; COMMENT ON COLUMN "common_codes"."updated_at" IS '공통 코드 수정 일시'; INSERT INTO "common_codes" ("group_key", "code", "label", "description", "sort_order") VALUES ('NOTIFICATION_CATEGORY', 'assignment', '과제', '과제 및 제출 관련 알림', 10), ('NOTIFICATION_CATEGORY', 'course', '강의', '강의 및 커리큘럼 관련 알림', 20), ('NOTIFICATION_CATEGORY', 'notice', '공지', '일반 공지 알림', 30), ('NOTIFICATION_CATEGORY', 'update', '업데이트', '업데이트 및 배포 알림', 40), ('NOTIFICATION_CATEGORY', 'system', '시스템', '시스템 운영 알림', 50) ON CONFLICT ("group_key", "code") DO UPDATE SET "label" = EXCLUDED."label", "description" = EXCLUDED."description", "sort_order" = EXCLUDED."sort_order", "is_active" = true, "updated_at" = CURRENT_TIMESTAMP;