From aa97c034a0f517eb0d0630e59e8f1c8d644149bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20V=C4=83n=20Rum=20=28VSF-QTVHNTDVX-PMGTCC?= =?UTF-8?q?=29?= Date: Mon, 8 Jun 2026 23:27:04 +0700 Subject: [PATCH] fix(prisma): don't require DATABASE_URL for `prisma generate`; bump version to 0.3.0 The Prisma 7 `prisma.config.ts` used `env('DATABASE_URL')`, which Prisma 7 evaluates eagerly and throws on when the var is missing. The Docker image build runs `npx prisma generate` (no DB needed) without DATABASE_URL set, so the Release workflow failed at the generate step. Attach the datasource only when DATABASE_URL is present (via process.env), so generate works in the image build while migrate/introspection still get the URL when it is set. Also bump package.json version to 0.3.0. --- package.json | 2 +- prisma.config.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d707ced..5ff4b6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "temlet", - "version": "0.1.0", + "version": "0.3.0", "description": "Self-hosted video rendering and upload management for After Effects projects — render with nexrender, auto-generate metadata, and schedule uploads to YouTube and TikTok.", "type": "module", "license": "MIT", diff --git a/prisma.config.ts b/prisma.config.ts index d8bc87f..b5ac686 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -1,5 +1,5 @@ import path from 'node:path'; -import { defineConfig, env } from 'prisma/config'; +import { defineConfig } from 'prisma/config'; /** * Prisma 7 moved the Migrate/introspection connection URL out of @@ -7,13 +7,18 @@ import { defineConfig, env } from 'prisma/config'; * connects via a pg driver adapter (see `lib/prisma.ts`); this datasource * block is only used by Prisma CLI commands (migrate, db pull, studio). * - * `DATABASE_URL` is provided by the environment (`.env` in dev, CI secret in - * CI). Prisma 7 no longer auto-loads `.env`, so populate the shell env (or use + * The datasource is attached only when `DATABASE_URL` is present. This keeps + * `prisma generate` (which needs no DB) working in environments where the + * variable is unset — notably the Docker image build. Migrate/introspection + * commands require a real URL and will have it set. Using `process.env` + * instead of Prisma's `env()` helper avoids its eager throw on a missing var. + * + * Prisma 7 no longer auto-loads `.env`, so populate the shell env (or use * `dotenv -e .env -- prisma ...`) when running migrations locally. */ +const databaseUrl = process.env.DATABASE_URL; + export default defineConfig({ schema: path.join('prisma', 'schema.prisma'), - datasource: { - url: env('DATABASE_URL'), - }, + ...(databaseUrl ? { datasource: { url: databaseUrl } } : {}), });