Repository navigation
build: apply Payload migrations automatically on Vercel deploys - #113
Merged
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Deploys only ran
next build, so schema changes required a manualpnpm 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: newvercel-buildscript —pnpm run db:migrate && pnpm run build. Vercel usesvercel-buildinstead ofbuildwhen it exists, so every deployment applies pending Payload migrations to its own Neon branch (Preview → development, Production → production) overDATABASE_URL_UNPOOLED, then builds (postbuild sitemap unchanged).docs/deployment.mdandREADME.mddocument the behavior, its requirements and the backward-compatibility rule for future migrations.Requirements (Vercel settings)
vercel-build).DATABASE_URL_UNPOOLED,DATABASE_URLandPAYLOAD_SECRETavailable to builds in Preview and Production.Verification
Locally against PostgreSQL: with one pending migration,
pnpm run db:migrateapplied it non-interactively; a second run with nothing pending exited 0 with no prompt. The Vercel build log of this PR's preview should showMigrating: …lines for the development branch (or nothing if already applied) beforenext build.