Skip to content

fix(deploy): tolerate P3005 (prod schema not baselined) in build#29

Merged
abdout merged 1 commit into
mainfrom
fix/migrate-baseline-tolerance
May 10, 2026
Merged

fix(deploy): tolerate P3005 (prod schema not baselined) in build#29
abdout merged 1 commit into
mainfrom
fix/migrate-baseline-tolerance

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented May 10, 2026

Hotfix. Unblocks the Vercel deploy pipeline that broke after #25.

What broke

Vercel deploys on main are failing with:

Error: P3005
The database schema is not empty. Read more about how to baseline an
existing production database: https://pris.ly/d/migrate-baseline
❌ prisma migrate deploy failed

This means production was populated via prisma db push or equivalent — the schema exists but _prisma_migrations is empty, so migrate deploy refuses to run pending migrations because it can't tell what's already applied.

Effect

Every push to main since #25 has been blocked. The latest deploy stuck on main is the pre-#28 code, which still has the autocomplete LIMIT == COUNT bug. PRs #19, #22, #23, #24, #26, #27, #28 are all merged on main but not live — Vercel hasn't successfully deployed any commit since #25 went in.

Fix

scripts/maybe-migrate.mjs now catches P3005 specifically, logs an actionable warning with the baseline commands, and exits 0. Other errors still fail the build.

if (combined.includes("P3005")) {
  console.warn(
    "⚠️  P3005: production schema is not baselined — skipping migrate deploy.\n" +
    "    Pending migrations will NOT be applied automatically.\n" +
    "    To baseline (one-time): for each existing migration directory, run\n" +
    "      pnpm exec prisma migrate resolve --applied <migration_name>\n" +
    "    against production DATABASE_URL, then redeploy."
  );
  process.exit(0);
}

Trade-off: pending migrations (the new pg_trgm + listing-indexes ones) don't auto-apply. They land on the database only after a one-time baseline operation. Until then, the new code falls back to its safe paths:

  • getLocationSuggestionstry/catch returns [] if pg_trgm missing
  • getFullTextMatchingIds → same graceful fallback

After this lands

  1. Immediate: prod gets up-to-date code (six PRs' worth) including the count-bug hotfix.
  2. Next: a follow-up baseline operation against prod — for each existing migration directory:
    DATABASE_URL='<prod>' pnpm exec prisma migrate resolve --applied 20250720124004_init_with_listing
    # ... repeat for each
    Then a redeploy applies the pending pg_trgm + listing-indexes migrations.

🤖 Generated with Claude Code

Vercel deploys started failing after #25 because production was
populated via 'prisma db push' (or equivalent) with no migration
history. 'prisma migrate deploy' refuses with P3005 in that state
because it can't tell which migrations are already applied — and
running them blindly would re-create existing tables.

Until the prod database is baselined, treat P3005 as 'skip and
continue' so deploys still ship. Pending migrations don't apply
(they'll need a one-time manual baseline + redeploy), but the rest
of the build proceeds normally.

The warning prints the exact baseline commands so an operator can
do this safely when ready:
  pnpm exec prisma migrate resolve --applied <migration_name>
… for each existing migration, then redeploy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mkan Ready Ready Preview, Comment May 10, 2026 6:28am

@abdout abdout merged commit f6eb78a into main May 10, 2026
8 checks passed
@abdout abdout deleted the fix/migrate-baseline-tolerance branch May 10, 2026 06:28
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