Skip to content

build: apply Payload migrations automatically on Vercel deploys - #113

Merged
EagleFox31 merged 1 commit into
mainfrom
claude/clarification-needed-k2rby5
Oct 12, 2026
Merged

EagleFox31 merged 1 commit into
mainfrom
claude/clarification-needed-k2rby5

Conversation

@EagleFox31

@EagleFox31 EagleFox31 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Why

Deploys only ran next build, so schema changes required a manual pnpm db:migrate. After #110 was merged, production is running code that expects the new tables (posts_key_takeaways, posts_faq, users_locales, users_texts, users_profile_links) before they exist. Merging this PR triggers a production deploy that applies them.

What

  • package.json: new vercel-build script — pnpm run db:migrate && pnpm run build. Vercel uses vercel-build instead of build when it exists, so every deployment applies pending Payload migrations to its own Neon branch (Preview → development, Production → production) over DATABASE_URL_UNPOOLED, then builds (postbuild sitemap unchanged).
  • Already-applied migrations are skipped; a failed migration fails the build and the previous deployment keeps serving.
  • docs/deployment.md and README.md document the behavior, its requirements and the backward-compatibility rule for future migrations.

Requirements (Vercel settings)

  • Build Command left on its default (an override bypasses vercel-build).
  • DATABASE_URL_UNPOOLED, DATABASE_URL and PAYLOAD_SECRET available to builds in Preview and Production.

Verification

Locally against PostgreSQL: with one pending migration, pnpm run db:migrate applied it non-interactively; a second run with nothing pending exited 0 with no prompt. The Vercel build log of this PR's preview should show Migrating: … lines for the development branch (or nothing if already applied) before next build.

Add a vercel-build script that runs db:migrate over the direct Neon
connection before next build, so each environment migrates its own Neon
branch on deploy instead of relying on a manual step.
@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
trigenys-insight Ready Ready Preview Oct 11, 2026 11:47pm UTC

@EagleFox31
EagleFox31 merged commit 58d75ec into main Oct 12, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 580a864e Deployed Oct 11, 2026 by vercel[bot]
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