Skip to content

fix(react-router-example): fallback to dummy database url in prisma config for CI#40

Merged
kattsushi merged 2 commits into
masterfrom
fix/react-router-example-pipeline
Feb 9, 2026
Merged

fix(react-router-example): fallback to dummy database url in prisma config for CI#40
kattsushi merged 2 commits into
masterfrom
fix/react-router-example-pipeline

Conversation

@kattsushi

@kattsushi kattsushi commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

This PR resolves the CD failure where prisma generate fails due to missing DATABASE_URL.

  • Added fallback dummy URL in prisma.config.ts.
  • Updated schema.prisma to use env("DATABASE_URL").

Summary by CodeRabbit

  • Chores
    • Improved database configuration to support environment variables with automatic fallback to local PostgreSQL for development, streamlining setup.

@coderabbitai

coderabbitai Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request adds Prisma datasource URL configuration with a fallback to a local PostgreSQL instance when the DATABASE_URL environment variable is not set, allowing Prisma generate to run without external database connectivity.

Changes

Cohort / File(s) Summary
Prisma Configuration
apps/react-router-example/prisma.config.ts, apps/react-router-example/prisma/schema.prisma
Added environment-based DATABASE_URL configuration with a nullish coalescing fallback to postgresql://postgres:postgres@localhost:5432/effectify for local development setup.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • UI example app: Pico CSS #27: Modifies Prisma initialization to validate DATABASE_URL, directly related to how the environment variable is handled across the project.

Poem

🐰 A rabbit hops through schemas so fine,
With DATABASE_URL as a fallback line,
When env vars hide in their burrow deep,
localhost stands guard o'er the data to keep,
No tunnels to dig, just config so neat! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a fallback dummy database URL to fix CI pipeline failures caused by missing DATABASE_URL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/react-router-example-pipeline

Comment @coderabbitai help to get the list of available commands and usage tips.

@kattsushi

Copy link
Copy Markdown
Contributor Author

Actualización: Se ha eliminado la propiedad url de prisma/schema.prisma para cumplir con los requerimientos de Prisma v7, manteniendo la configuración en prisma.config.ts. Esto soluciona el error P1012 reportado en CI.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/react-router-example/prisma.config.ts`:
- Around line 11-15: The datasource url fallback currently uses
env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/..." which
masks missing DATABASE_URL in dev; change it to only apply the hardcoded
fallback when running in CI (e.g. when process.env.CI === "true" or a dedicated
CI flag) so local/machine runs fail fast; update the datasource.url expression
to check process.env.CI (or similar) and only return the localhost fallback in
CI, keeping the runtime guard in app/lib/prisma.ts intact.

Comment on lines 11 to 15
datasource: {
url: env("DATABASE_URL"),
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "prisma.config.ts" -type f

Repository: devx-op/effectify

Length of output: 140


🏁 Script executed:

cat -n ./apps/react-router-example/prisma.config.ts

Repository: devx-op/effectify

Length of output: 765


🏁 Script executed:

git log --oneline -n 10 -- ./apps/react-router-example/prisma.config.ts

Repository: devx-op/effectify

Length of output: 146


🏁 Script executed:

find ./apps/react-router-example -type f \( -name "*.yml" -o -name "*.yaml" -o -name ".env*" \) | head -20

Repository: devx-op/effectify

Length of output: 107


🏁 Script executed:

rg "CI|DATABASE_URL" ./apps/react-router-example --type ts --type js -A 2 -B 2

Repository: devx-op/effectify

Length of output: 1231


🏁 Script executed:

cat -n ./apps/react-router-example/docker-compose.yml

Repository: devx-op/effectify

Length of output: 417


🏁 Script executed:

cat -n ./apps/react-router-example/app/lib/prisma.ts

Repository: devx-op/effectify

Length of output: 681


Restrict fallback URL to CI only; avoid masking misconfiguration in dev.

The unconditional fallback to localhost:5432 risks silent misconfiguration during development. If DATABASE_URL is missing when running prisma CLI commands, it will silently connect to the hardcoded local database instead of failing fast. Additionally, the fallback port (5432) differs from the docker-compose setup (5433), compounding the risk.

While runtime protection exists in app/lib/prisma.ts (which enforces DATABASE_URL), the config-level fallback still creates friction during local development. Restrict the fallback to CI environments only:

+const databaseUrl =
+  env("DATABASE_URL") ??
+  (process.env.CI ? "postgresql://postgres:postgres@localhost:5432/effectify" : undefined)
+
+if (!databaseUrl && !process.env.CI) {
+  throw new Error("DATABASE_URL is required outside CI")
+}
+
 export default defineConfig({
   schema: "prisma/schema.prisma",
   migrations: {
     path: "prisma/migrations",
   },
   datasource: {
     // Provide a default value for CI/CD environments where the database URL is not set
     // This allows prisma generate to run without connecting to the database
-    url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
+    url: databaseUrl,
   },
 })
📝 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
datasource: {
url: env("DATABASE_URL"),
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
},
const databaseUrl =
env("DATABASE_URL") ??
(process.env.CI ? "postgresql://postgres:postgres@localhost:5432/effectify" : undefined)
if (!databaseUrl && !process.env.CI) {
throw new Error("DATABASE_URL is required outside CI")
}
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: databaseUrl,
},
})
🤖 Prompt for AI Agents
In `@apps/react-router-example/prisma.config.ts` around lines 11 - 15, The
datasource url fallback currently uses env("DATABASE_URL") ??
"postgresql://postgres:postgres@localhost:5432/..." which masks missing
DATABASE_URL in dev; change it to only apply the hardcoded fallback when running
in CI (e.g. when process.env.CI === "true" or a dedicated CI flag) so
local/machine runs fail fast; update the datasource.url expression to check
process.env.CI (or similar) and only return the localhost fallback in CI,
keeping the runtime guard in app/lib/prisma.ts intact.

@kattsushi kattsushi merged commit df32c3d into master Feb 9, 2026
6 checks passed
kattsushi added a commit that referenced this pull request Mar 15, 2026
…onfig for CI (#40)

* fix(react-router-example): fallback to dummy database url in prisma config for CI

* fix(react-router-example): remove url from schema.prisma to support prisma v7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant