Skip to content

[fix] Issue-994 Add: standard procedure for mongoDB-migrations#1005

Closed
AryaDharkar wants to merge 1 commit intostagefrom
994-add-mongodb-migrations-setup
Closed

[fix] Issue-994 Add: standard procedure for mongoDB-migrations#1005
AryaDharkar wants to merge 1 commit intostagefrom
994-add-mongodb-migrations-setup

Conversation

@AryaDharkar
Copy link
Copy Markdown
Member

Description

#994

What type of PR is this? (Check all applicable)

  • 🍕 Feature

What this PR does

Sets up the migration infrastructure so schema changes can be made safely without breaking production.

Changes

  • Added migrate-mongo package
  • Added migrate-mongo-config.js at packages/app root
  • Added migrations/ directory with .gitkeep and _template.js for engineer reference
  • Added migrate:up, migrate:down, migrate:status scripts to package.json
  • Updated vercel.json to run migrate:up automatically before every deployment

Why

Adding required: true fields 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

  1. npx migrate-mongo create <name> — generate a migration file
  2. Fill in up() to backfill the field and down() to undo it
  3. Deploy with the field as optional first, then required in a follow-up deploy

Refer to the migration guide in Notion for the full process.
https://www.notion.so/mongodb-migration-guide-337fefb8307180029b2de948a9794017?source=copy_link

Testing

  • Verified locally: migrate:up, migrate:status, and migrate:down all work correctly
  • Verified on Vercel: migration step runs in build logs before deployment completes

@AryaDharkar AryaDharkar linked an issue Apr 17, 2026 that may be closed by this pull request
2 tasks
@github-actions github-actions Bot added the enhancement New feature or request label Apr 17, 2026
@AryaDharkar AryaDharkar changed the title Add: standard procedure for mongoDB-migrations Issue 994: Add: standard procedure for mongoDB-migrations Apr 17, 2026
@AryaDharkar AryaDharkar changed the title Issue 994: Add: standard procedure for mongoDB-migrations [fix ]Issue 994: Add: standard procedure for mongoDB-migrations Apr 17, 2026
@AryaDharkar AryaDharkar changed the title [fix ]Issue 994: Add: standard procedure for mongoDB-migrations [fix]Issue 994: Add: standard procedure for mongoDB-migrations Apr 17, 2026
@AryaDharkar AryaDharkar changed the title [fix]Issue 994: Add: standard procedure for mongoDB-migrations [fix] Issue-994 Add: standard procedure for mongoDB-migrations Apr 17, 2026
@sonarqubecloud
Copy link
Copy Markdown

@AryaDharkar AryaDharkar deleted the 994-add-mongodb-migrations-setup branch April 17, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.8.0 Add: MongoDB migrations setup

1 participant