Hi Vsme,
I’d treat this as a potentially risky env/branch-mapping issue and disable any automatic migration-on-start behavior until you confirm which database the v0 chat is actually using.
A safe way to debug it is to log only the environment and Neon host/branch, not the full connection string or password:
1console.log({2 vercelEnv: process.env.VERCEL_ENV,3 publicVercelEnv: process.env.NEXT_PUBLIC_VERCEL_ENV,4 databaseHost: process.env.DATABASE_URL5 ? new URL(process.env.DATABASE_URL).host6 : "missing",7})8
If the v0 chat/preview shows production or points at the same Neon host/branch as production, then I would not run migrations from that environment.
In Vercel, I’d also check:
1Project Settings → Environment Variables2
and confirm whether DATABASE_URL / POSTGRES_URL have separate values for Production and Preview. Preview env vars are used for non-production branches, and branch-specific Preview values can override the general Preview value.
Neon’s Vercel preview integration is supposed to create a preview/<git-branch> branch and inject the connection string into that deployment, so if that branch is not being created, I’d check the Neon integration events and branch limit first:
https://neon.tech/docs/guides/vercel-previews-integration
For now, I’d make the app defensive:
1if (process.env.VERCEL_ENV === "production") {2 // never run dev/reset/auto migrations here3}4
and only allow destructive or auto migrations when an explicit non-production flag is set, for example ALLOW_PREVIEW_MIGRATIONS=true.
Can you share whether the v0 chat is connected to a Git branch that creates a normal Vercel Preview Deployment, or whether it is running only inside the v0 preview/chat environment?