chore(prisma): prisma.config.ts 统一环境加载(NODE_ENV 分文件 + 迁移镜像收口) - #38
Merged
Merged
Conversation
load .env.<NODE_ENV> (default development) with warn-only missing-file behavior for CI/containers keep package.json prisma.seed as fallback (config takes precedence) COPY prisma.config.ts into migrate image for unified prod rules
youdingtianzhaogeyinzuo
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更文件清单(4 个)
prisma.config.ts(新增):按 NODE_ENV ∈ {development, test, production}(缺省 development)加载<仓库根>/.env.<NODE_ENV>;文件缺失仅告警不阻断。package.json:devDependencies 新增dotenv@^16.6.1(npm install 时自动把 dependencies 中@keyv/redis按字母序归位,纯顺序调整无功能变化)。package-lock.json:对应 dotenv 依赖锁定。Dockerfile.migrate:新增COPY prisma.config.ts ./(收口到迁移镜像,镜像内 NODE_ENV=production 且无 env 文件 → 走 warn 容错路径)。设计要点
.env.<NODE_ENV>缺失只打印[prisma.config] 环境文件不存在 ...不阻断。已过验证门
npm run typecheck→ 0npx prisma version(本地 .env.development 存在)→ 0,无缺失告警NODE_ENV=production npx prisma version→ stderr 出现[prisma.config] 环境文件不存在 ... .env.production且退出码 0npm run prisma:generate(含 .env.development 临时改名干净环境)→ 缺失告警 + 退出码 0,文件已恢复npm run db:reset(守卫:host 为 localhost 且可达)→ 0,含Running seed command+ 种子摘要npm run prisma:seed→ 0,种子摘要一致(已存在数据跳过,幂等)docker build -f Dockerfile.migrate -t booking-migrate:config-smoke .→ 0docker run --rm booking-migrate:config-smoke npx prisma version→ stderr环境文件不存在: /app/.env.production (NODE_ENV=production)且退出码 0(设计内状态,未打印任何 DATABASE_URL)CI 说明