Files
2026-07-01 17:30:04 +09:00

66 lines
3.0 KiB
SQL

-- CreateTable
CREATE TABLE "runtime_env_profiles" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"app_id" UUID NOT NULL,
"name" TEXT NOT NULL,
"environment" TEXT NOT NULL,
"namespace" TEXT NOT NULL,
"is_active" BOOLEAN NOT NULL DEFAULT true,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(3) NOT NULL,
CONSTRAINT "runtime_env_profiles_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "runtime_env_variables" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"profile_id" UUID NOT NULL,
"component_id" UUID,
"key" TEXT NOT NULL,
"value" TEXT NOT NULL,
"is_secret" BOOLEAN NOT NULL DEFAULT false,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(3) NOT NULL,
CONSTRAINT "runtime_env_variables_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "runtime_env_profiles_app_id_environment_name_key" ON "runtime_env_profiles"("app_id", "environment", "name");
-- CreateIndex
CREATE INDEX "runtime_env_profiles_app_id_environment_idx" ON "runtime_env_profiles"("app_id", "environment");
-- CreateIndex
CREATE UNIQUE INDEX "runtime_env_variables_profile_id_component_id_key_key" ON "runtime_env_variables"("profile_id", "component_id", "key");
-- CreateIndex
CREATE INDEX "runtime_env_variables_profile_id_is_secret_idx" ON "runtime_env_variables"("profile_id", "is_secret");
-- CreateIndex
CREATE INDEX "runtime_env_variables_component_id_idx" ON "runtime_env_variables"("component_id");
-- AddForeignKey
ALTER TABLE "runtime_env_profiles" ADD CONSTRAINT "runtime_env_profiles_app_id_fkey" FOREIGN KEY ("app_id") REFERENCES "apps"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "runtime_env_variables" ADD CONSTRAINT "runtime_env_variables_profile_id_fkey" FOREIGN KEY ("profile_id") REFERENCES "runtime_env_profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "runtime_env_variables" ADD CONSTRAINT "runtime_env_variables_component_id_fkey" FOREIGN KEY ("component_id") REFERENCES "app_components"("id") ON DELETE SET NULL ON UPDATE CASCADE;
COMMENT ON TABLE "runtime_env_profiles" IS '앱별 런타임 환경 프로파일';
COMMENT ON COLUMN "runtime_env_profiles"."app_id" IS '앱 ID';
COMMENT ON COLUMN "runtime_env_profiles"."name" IS '프로파일명';
COMMENT ON COLUMN "runtime_env_profiles"."environment" IS '배포 환경';
COMMENT ON COLUMN "runtime_env_profiles"."namespace" IS '적용 namespace';
COMMENT ON COLUMN "runtime_env_profiles"."is_active" IS '활성 여부';
COMMENT ON TABLE "runtime_env_variables" IS '런타임 환경변수 및 시크릿';
COMMENT ON COLUMN "runtime_env_variables"."profile_id" IS '런타임 환경 프로파일 ID';
COMMENT ON COLUMN "runtime_env_variables"."component_id" IS '적용 구성요소 ID';
COMMENT ON COLUMN "runtime_env_variables"."key" IS '환경변수 키';
COMMENT ON COLUMN "runtime_env_variables"."value" IS '환경변수 값';
COMMENT ON COLUMN "runtime_env_variables"."is_secret" IS 'Secret 적용 여부';