Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix prisma config ts to include datasource URL
  • Loading branch information
kingston committed Dec 22, 2025
commit b3a6031e0c1a3ff51fe6885caaa10d4ce6175f63
2 changes: 1 addition & 1 deletion examples/blog-with-auth/apps/backend/.templates-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"instanceData": {},
"template": "eslint-config"
},
"prisma.config.mts": {
"prisma.config.ts": {
"generator": "@baseplate-dev/fastify-generators#prisma/prisma",
"instanceData": {},
"template": "prisma-config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@baseplate-dev/fastify-generators#prisma/data-utils:relation-helpers": "src/utils/data-operations/relation-helpers.ts",
"@baseplate-dev/fastify-generators#prisma/data-utils:types": "src/utils/data-operations/types.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:client": "src/generated/prisma/client.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-config": "prisma.config.mts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-config": "prisma.config.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-schema": "prisma/schema.prisma",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-seed-env": ".seed.env",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-seed-env-example": ".seed.env.example",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const IGNORE_FILES = /* TPL_IGNORE_FILES:START */ [
// Specifies which files should use the default tsconfig.json project
// This is useful for certain files outside the src directory, e.g. config files
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import type { PrismaConfig } from 'prisma';

import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig, env } from 'prisma/config';

// Only load .env file if it exists
if (existsSync('.env')) {
loadEnvFile();
}

export default {
export default defineConfig({
schema: './prisma/schema.prisma',
migrations: {
path: './prisma/migrations',
seed: /* TPL_SEED_COMMAND:START */ 'tsx --env-file-if-exists=.env --env-file-if-exists=.seed.env src/prisma/seed.ts' /* TPL_SEED_COMMAND:END */,
},
} satisfies PrismaConfig;
datasource: {
url: env('DATABASE_URL'),
},
});
2 changes: 1 addition & 1 deletion examples/blog-with-auth/apps/backend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const IGNORE_FILES = /* TPL_IGNORE_FILES:START */ [
// Specifies which files should use the default tsconfig.json project
// This is useful for certain files outside the src directory, e.g. config files
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
Comment on lines 37 to 41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove duplicate vitest.config.ts entry.

Lines 39-40 contain duplicate entries of 'vitest.config.ts' in the TS_DEFAULT_PROJECT_FILES array.

🔎 Proposed fix
 const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
   'prisma.config.ts',
   'vitest.config.ts',
-  'vitest.config.ts',
 ]; /* TPL_DEFAULT_PROJECT_FILES:END */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
🤖 Prompt for AI Agents
In examples/blog-with-auth/apps/backend/eslint.config.js around lines 37 to 41,
the TS_DEFAULT_PROJECT_FILES array contains a duplicated 'vitest.config.ts'
entry; remove the duplicate so the array lists each filename only once (e.g.,
keep one 'vitest.config.ts' and the other entries unchanged) to ensure the
project files array has unique entries.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import type { PrismaConfig } from 'prisma';

import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig, env } from 'prisma/config';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use the imported env helper instead of process.env.DATABASE_URL.

The env helper from prisma/config is imported but never used. Use the env() helper to enforce that the environment variable exists. Replace process.env.DATABASE_URL on line 17 with env('DATABASE_URL') to follow Prisma 7 best practices.

🧰 Tools
🪛 GitHub Check: Lint Examples (blog-with-auth)

[failure] 3-3:
'env' is defined but never used

🤖 Prompt for AI Agents
In examples/blog-with-auth/apps/backend/prisma.config.ts around line 3 and
specifically line 17, the imported env helper from 'prisma/config' is unused and
the code reads process.env.DATABASE_URL; replace the direct process.env access
with env('DATABASE_URL') so the Prisma config validates the variable at startup,
keeping the existing import and removing reliance on raw process.env access.


// Only load .env file if it exists
if (existsSync('.env')) {
loadEnvFile();
}

export default {
export default defineConfig({
schema: './prisma/schema.prisma',
migrations: {
path: './prisma/migrations',
seed: /* TPL_SEED_COMMAND:START */ 'tsx --env-file-if-exists=.env --env-file-if-exists=.seed.env src/prisma/seed.ts' /* TPL_SEED_COMMAND:END */,
},
} satisfies PrismaConfig;
datasource: {
url: env('DATABASE_URL'),
},
});
2 changes: 1 addition & 1 deletion examples/todo-with-auth0/apps/backend/.templates-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"instanceData": {},
"template": "eslint-config"
},
"prisma.config.mts": {
"prisma.config.ts": {
"generator": "@baseplate-dev/fastify-generators#prisma/prisma",
"instanceData": {},
"template": "prisma-config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@baseplate-dev/fastify-generators#prisma/data-utils:relation-helpers": "src/utils/data-operations/relation-helpers.ts",
"@baseplate-dev/fastify-generators#prisma/data-utils:types": "src/utils/data-operations/types.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:client": "src/generated/prisma/client.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-config": "prisma.config.mts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-config": "prisma.config.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:prisma-schema": "prisma/schema.prisma",
"@baseplate-dev/fastify-generators#prisma/prisma:seed": "src/prisma/seed.ts",
"@baseplate-dev/fastify-generators#prisma/prisma:service": "src/services/prisma.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const IGNORE_FILES = /* TPL_IGNORE_FILES:START */ [
// Specifies which files should use the default tsconfig.json project
// This is useful for certain files outside the src directory, e.g. config files
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import type { PrismaConfig } from 'prisma';

import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig, env } from 'prisma/config';

// Only load .env file if it exists
if (existsSync('.env')) {
loadEnvFile();
}

export default {
export default defineConfig({
schema: './prisma/schema.prisma',
migrations: {
path: './prisma/migrations',
seed: /* TPL_SEED_COMMAND:START */ 'tsx --env-file-if-exists=.env --env-file-if-exists=.seed.env src/prisma/seed.ts' /* TPL_SEED_COMMAND:END */,
},
} satisfies PrismaConfig;
datasource: {
url: env('DATABASE_URL'),
},
});
2 changes: 1 addition & 1 deletion examples/todo-with-auth0/apps/backend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const IGNORE_FILES = /* TPL_IGNORE_FILES:START */ [
// Specifies which files should use the default tsconfig.json project
// This is useful for certain files outside the src directory, e.g. config files
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
Comment on lines 37 to 41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove duplicate vitest.config.ts entry.

Lines 39-40 contain duplicate entries of 'vitest.config.ts' in the TS_DEFAULT_PROJECT_FILES array.

🔎 Proposed fix
 const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
   'prisma.config.ts',
   'vitest.config.ts',
-  'vitest.config.ts',
 ]; /* TPL_DEFAULT_PROJECT_FILES:END */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.mts',
'prisma.config.ts',
'vitest.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
const TS_DEFAULT_PROJECT_FILES = /* TPL_DEFAULT_PROJECT_FILES:START */ [
'prisma.config.ts',
'vitest.config.ts',
]; /* TPL_DEFAULT_PROJECT_FILES:END */
🤖 Prompt for AI Agents
In examples/todo-with-auth0/apps/backend/eslint.config.js around lines 37 to 41,
the TS_DEFAULT_PROJECT_FILES array contains a duplicate 'vitest.config.ts'
entry; remove the duplicated 'vitest.config.ts' so each file appears only once
(leave 'prisma.config.ts' and one 'vitest.config.ts').

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import type { PrismaConfig } from 'prisma';

import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig, env } from 'prisma/config';

// Only load .env file if it exists
if (existsSync('.env')) {
loadEnvFile();
}

export default {
export default defineConfig({
schema: './prisma/schema.prisma',
migrations: {
path: './prisma/migrations',
seed: /* TPL_SEED_COMMAND:START */ 'tsx --env-file-if-exists=.env --env-file-if-exists=.seed.env src/prisma/seed.ts' /* TPL_SEED_COMMAND:END */,
},
} satisfies PrismaConfig;
datasource: {
url: env('DATABASE_URL'),
},
});
2 changes: 1 addition & 1 deletion packages/fastify-generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@baseplate-dev/core-generators": "workspace:*",
"@baseplate-dev/sync": "workspace:*",
"@baseplate-dev/utils": "workspace:*",
"@prisma/internals": "6.17.1",
"@prisma/internals": "7.2.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Verify Prisma/internals version and address breaking changes before upgrade.

Prisma 7.2.0 is released and stable, but this major version introduces significant breaking changes and unresolved security concerns that require attention:

Breaking Changes:
Environment variables are not loaded by default in Prisma 7.0.0; developers must explicitly load them when calling the Prisma CLI. Additionally, as of Prisma 7, driver adapters are required, and Prisma Config is now the default place for configuring database URL, schema location, and migrations.

Security Concerns:
Prisma 7 depends on hono <=4.10.2, which has multiple high-severity vulnerabilities including body limit middleware bypass, improper authorization, and CORS bypass. This was confirmed to be fixed in Prisma 7.0.1, though ongoing issues have been reported.

Note: The specified version @prisma/[email protected] differs from the latest published version (7.0.1). Verify the correct version and ensure all configuration changes for Prisma 7 are addressed.

🤖 Prompt for AI Agents
packages/fastify-generators/package.json around line 53: the dependency is
pinned to @prisma/[email protected] which may introduce Prisma v7 breaking changes
and known security issues (hono vulnerabilities); change the dependency to a
vetted safe version (e.g., 7.0.1) or the semver range your project supports, run
dependency install and npm/yarn audit, update any Prisma v7 configuration
(explicitly load env vars where Prisma CLI is used, add required driver
adapters, and move DB config to Prisma Config if upgrading), run the test suite
and migration scripts to catch breaking changes, and if you must keep 7.2.0
create a mitigation plan (patch or upgrade hono transitive dep, or add a direct
safe hono resolution) and document the rationale in package.json or PR notes.

"change-case": "5.4.4",
"es-toolkit": "1.31.0",
"indent-string": "5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"type": "ts",
"fileOptions": { "kind": "singleton" },
"importMapProviders": {},
"pathRootRelativePath": "{package-root}/prisma.config.mts",
"sourceFile": "package/prisma.config.mts",
"pathRootRelativePath": "{package-root}/prisma.config.ts",
"sourceFile": "package/prisma.config.ts",
"variables": { "TPL_SEED_COMMAND": {} }
},
"seed": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const prismaPrismaPathsTask = createGeneratorTask({
providers: {
prismaPrismaPaths: {
client: `${srcRoot}/generated/prisma/client.ts`,
prismaConfig: `${packageRoot}/prisma.config.mts`,
prismaConfig: `${packageRoot}/prisma.config.ts`,
seed: `${srcRoot}/prisma/seed.ts`,
service: `${srcRoot}/services/prisma.ts`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const prismaConfig = createTsTemplateFile({
source: {
path: path.join(
import.meta.dirname,
'../templates/package/prisma.config.mts',
'../templates/package/prisma.config.ts',
),
},
variables: { TPL_SEED_COMMAND: {} },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const prismaGenerator = createGenerator({
prettier: prettierProvider,
},
run({ eslintConfig, prettier }) {
eslintConfig.tsDefaultProjectFiles.push('prisma.config.mts');
eslintConfig.tsDefaultProjectFiles.push('prisma.config.ts');
eslintConfig.eslintIgnore.push('src/generated/prisma/**/*.ts');
prettier.addPrettierIgnore('src/generated/prisma/**/*.ts');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// @ts-nocheck

import type { PrismaConfig } from 'prisma';

import { existsSync } from 'node:fs';
import { loadEnvFile } from 'node:process';
import { defineConfig, env } from 'prisma/config';

// Only load .env file if it exists
if (existsSync('.env')) {
loadEnvFile();
}

export default {
export default defineConfig({
schema: './prisma/schema.prisma',
migrations: {
path: './prisma/migrations',
seed: TPL_SEED_COMMAND,
},
} satisfies PrismaConfig;
datasource: {
url: env('DATABASE_URL'),
},
});
Loading
Loading