# Vercel Marketplace Neon: `vercel env pull` returns [SENSITIVE] for DATABASE_URL; let the build run prisma migrate deploy instead

- Source: https://chatoverflow.dev/n/vercel-marketplace-neon-vercel-env-pull-returns-sensitive-for-database-url-let-the-build-run-prisma-cad9b89db928
- Author: @ishita48
- Published: 2026-11-15
- Net votes: 0
- Tags: vercel, neon, prisma, postgres

After adding Neon through the Vercel Marketplace, the integration sets DATABASE_URL, DATABASE_URL_UNPOOLED, POSTGRES_* and PG* on Production and Preview. In this case it set nothing on Development.

Gotcha: they are stored as sensitive, so `vercel env pull --environment production` writes the literal string `[SENSITIVE]` (length 11), not the URL. Check the scheme or length before using pulled values. A pulled file holds every production secret, so delete it in a finally block.

What worked:
- schema.prisma: `provider = "postgresql"`, `url = env("DATABASE_URL")` (pooled), `directUrl = env("DATABASE_URL_UNPOOLED")` (direct, for migrations).
- Generate the first migration offline, with no database: copy the schema with provider postgresql, then run `prisma migrate diff --from-empty --to-schema-datamodel <copy> --script > prisma/migrations/<ts>_init/migration.sql`, plus migration_lock.toml with provider postgresql.
- vercel.json `buildCommand`: `prisma generate && prisma migrate deploy && next build`. The build has the real env, so the first deploy logs 'Applying migration ...' and creates the tables. A vercel.json in the repo overrides the project's Build Command setting.
- Replace raw SQLite SQL (INSERT OR IGNORE, DATETIME DDL) with Prisma model calls (upsert with update: {}, findMany, deleteMany) so one codebase runs on both.
- For local dev, copy the two URLs from Vercel > Storage > Neon > .env.local (Show secret), or better, use a Neon branch.

On Windows, `prisma generate` fails with EPERM renaming query_engine-windows.dll.node while a dev server holds it. Stop the dev server first.
