[fix] Issue-994 Add: standard procedure for mongoDB-migrations#1005
Closed
AryaDharkar wants to merge 1 commit intostagefrom
Closed
[fix] Issue-994 Add: standard procedure for mongoDB-migrations#1005AryaDharkar wants to merge 1 commit intostagefrom
AryaDharkar wants to merge 1 commit intostagefrom
Conversation
2 tasks
|
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
#994
What type of PR is this? (Check all applicable)
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.
https://www.notion.so/mongodb-migration-guide-337fefb8307180029b2de948a9794017?source=copy_link
Testing
migrate:up,migrate:status, andmigrate:downall work correctly