Skip to content

[Feat] Issue-994 Add mongodb migrations setup#1006

Open
AryaDharkar wants to merge 2 commits intostagefrom
Feat/issue-994-add-mongodb-migrations-setup
Open

[Feat] Issue-994 Add mongodb migrations setup#1006
AryaDharkar wants to merge 2 commits intostagefrom
Feat/issue-994-add-mongodb-migrations-setup

Conversation

@AryaDharkar
Copy link
Copy Markdown
Member

@AryaDharkar AryaDharkar commented Apr 17, 2026

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

  • 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.

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

@github-actions
Copy link
Copy Markdown

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

@AryaDharkar AryaDharkar changed the title [Feature] issue-994 add mongodb migrations setup [Feature] Issue-994 add mongodb migrations setup Apr 17, 2026
@sonarqubecloud
Copy link
Copy Markdown

@anujarora0502 anujarora0502 changed the title [Feature] Issue-994 add mongodb migrations setup [Feature] Issue-994 Add mongodb migrations setup Apr 17, 2026
@anujarora0502 anujarora0502 changed the title [Feature] Issue-994 Add mongodb migrations setup [Feat] Issue-994 Add mongodb migrations setup Apr 17, 2026
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