Skip to content

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

Open
0-mstrmind wants to merge 3 commits into
stagefrom
feat/issue-994-add-mongodb-migration-setup
Open

[Feat] Issue-994 Add mongodb migrations setup#1067
0-mstrmind wants to merge 3 commits into
stagefrom
feat/issue-994-add-mongodb-migration-setup

Conversation

@0-mstrmind

Copy link
Copy Markdown
Contributor

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

Credits: @AryaDharkar

@0-mstrmind
0-mstrmind requested a review from anujarora0502 July 4, 2026 19:46
@github-actions

github-actions Bot commented Jul 4, 2026

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

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@0-mstrmind
0-mstrmind requested a review from AryaDharkar July 5, 2026 02:49
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.

2 participants