[Feat] Issue-994 Add mongodb migrations setup#1006
Open
AryaDharkar wants to merge 2 commits intostagefrom
Open
[Feat] Issue-994 Add mongodb migrations setup#1006AryaDharkar wants to merge 2 commits intostagefrom
AryaDharkar wants to merge 2 commits intostagefrom
Conversation
|
No linked issues found. Please add the corresponding issues in the pull request description. |
|
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.



Description
Issue #994
feat: standardise MongoDB schema migrations using migrate-mongo
What this PR does
Sets up the migration infrastructure so schema changes can be made safely without breaking production.
Changes
migrate-mongopackagemigrate-mongo-config.jsatpackages/approotmigrations/directory with.gitkeepand_template.jsfor engineer referencemigrate:up,migrate:down,migrate:statusscripts topackage.jsonvercel.jsonto runmigrate:upautomatically before every deploymentWhy
Adding
required: truefields to existing Mongoose models without backfilling existing documents crashes the app on deploy. This setup ensures migrations always run before new code goes live.How to make a schema change going forward
npx migrate-mongo create <name>— generate a migration fileup()to backfill the field anddown()to undo itRefer to the migration guide in Notion for the full process.
Testing
migrate:up,migrate:status, andmigrate:downall work correctly