Preview works, live 500? Run migrations

You added a notes field to bookings. In the builder preview, saving works. You deploy. On the live URL the page errors, or the Network tab shows a 500 and a message like "column notes does not exist". The front end shipped. The production database did not.

Sites built with Lovable, Bolt, Replit, v0 or Cursor hit this often. Preview receives the new table or column while you iterate. The live project keeps the old schema until someone applies the same SQL there.

The symptom

  • Preview creates, updates and lists the new field. The live URL fails on the same action.
  • The Network tab shows 400, 404 or 500 from your database API (for Supabase, a /rest/v1/ request).
  • The JSON error names a missing column, table or function: column ... does not exist, relation ... does not exist, or PostgREST Could not find the '…' column … in the schema cache.
  • Older screens still work. Redeploying the front end, a hard refresh and a private window do not help.
  • Client code may swallow the error, so the new field just stays blank.

The cause

A schema change is not a front-end deploy. A migration is SQL that must run against the database your live environment variables point at.

  • Two databases. Preview (or your laptop) and production are different projects. The column exists only in the one you edited.
  • Table-editor edits. Adding a column in the visual editor updates that one project and may never write a migration file.
  • Unapplied files. A file sits in supabase/migrations or prisma/migrations, but nobody ran supabase db push, prisma migrate deploy, or the host's release command against production.
  • ORM drift. You changed schema.prisma or a Drizzle schema and used db push locally. Production never saw those statements.
  • Functions and views. A new remote procedure, trigger or view was created in the preview SQL editor only.
  • Schema cache. Rarely, the column is already in Postgres but the API layer has not reloaded its cache yet.

Row level security can hide rows without an error. A missing column usually shows up in the API response body.

Step-by-step diagnosis

  1. Reproduce on the live URL with the Network tab open. Read the failing response body, not only the status code.
  2. Copy the missing name from the error (table, column or function).
  3. Confirm which database the live site uses. Check the production SUPABASE_URL, DATABASE_URL or project ref. Do not assume it matches preview.
  4. Inspect that database in the production SQL editor (or psql): select column_name from information_schema.columns where table_schema = 'public' and table_name = 'your_table' order by 1;
  5. Compare with preview. If the column is only there, you have schema lag, not an access-policy bug.
  6. Check migration history with supabase migration list or npx prisma migrate status against production.
  7. If the column is already present but the API still claims it is missing, reload the schema cache in Supabase (Settings, then API) and retry.

Fixes per builder or host

Lovable and Bolt

Open the backend the live URL actually uses, not only the table view in the builder canvas. Confirm a migration exists and that production shows the new column. When preview is ahead, run the same SQL in the production SQL editor, or push migrations to that project, then retry the live request.

v0 and Cursor (Next.js with Prisma, Drizzle or the Supabase CLI)

Put migrations in git. For Prisma, add prisma migrate deploy to the production release command; do not use prisma migrate dev on the host, and do not treat a local prisma db push as a production step. For Drizzle, run drizzle-kit migrate with the production DATABASE_URL. For Supabase, supabase link to the production project ref and run supabase db push.

Replit

Confirm deployment Secrets use the hosted database URL, not a local file that picked up columns during development. Run the same migration SQL against that hosted database, and add the mapper's migrate command to the production start or build step.

Any host (Vercel, Netlify, Render, Cloudflare)

Make schema migrate a named release step, separate from npm run build. Building TypeScript does not change Postgres. After the SQL succeeds, retry the live request; you usually do not need a second front-end deploy.

How to verify

  • Production information_schema includes the new table, column or function.
  • The same live request returns 200 and includes the new field in JSON.
  • Create, read and update on the live URL all persist the new field after a refresh.
  • Preview and production column lists match for the affected table.
  • prisma migrate status or supabase migration list shows no pending migration on production.

Prevention

  • Treat committed migration files as the source of truth. Avoid silent edits in a preview-only table editor.
  • Apply migrations as part of every production deploy, with a command the host runs automatically.
  • After any schema change, inspect production information_schema before you call the feature live.
  • Keep preview and production project refs obvious in environment variable names so you do not edit the wrong database.
  • When you add a remote procedure or view, ship it in the same migration folder as table changes.

Run the free 30-second check

Run the free 30-second check

← All posts

FlowCanary on SaaSHub