Skip to content

K13.5: keep previews and the demo off the production database - #139

Merged
MFrancis-dev merged 1 commit into
mainfrom
fix/preview-db
Nov 8, 2026
Merged

MFrancis-dev merged 1 commit into
mainfrom
fix/preview-db

Conversation

@MFrancis-dev

Copy link
Copy Markdown
Owner

Fix 4 from the pre-launch review (user data).

Problem: the Neon integration set the production DATABASE_URL for Production, Preview and Development, and vercel-build ran migrations on every build. A preview deploy would migrate and write the production database; vercel env pull followed by pnpm demo would point the local demo at it too.

Fix:

  • scripts/vercel-build.mjs: migrations only when VERCEL_ENV=production
  • databaseUrlFor() in lib/db/client.ts: on Preview/Development, ignore DATABASE_URL; use PREVIEW_DATABASE_URL or refuse to start with a clear message
  • pnpm demo clears DATABASE_URL (checked: Next keeps the empty value over .env.local)

Done in code rather than by removing the variable on Vercel: it's managed by the Neon integration, and a wrong env rm could take production's setting with it.

Tests: 3 new for databaseUrlFor. Docs: README status, ARCHITECTURE hosting, ESSENTIALS, .env.example, ROADMAP.

Closes #131

The Neon integration gives Preview and Development the production
DATABASE_URL, and every build ran migrations against it.

Closes #131
@MFrancis-dev
MFrancis-dev merged commit 3409040 into main Nov 8, 2026
4 checks passed
@MFrancis-dev
MFrancis-dev deleted the fix/preview-db branch November 8, 2026 09:13
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.

K13.5 Keep preview and development off the production database

2 participants