Skip to content

⚙️ Migration System with Node.js, Express, and MongoDB 🛠️

Notifications You must be signed in to change notification settings

RutvikMakvana4/Migration-System

Repository files navigation

⚙️ Migration System 🛠️

  • In MongoDB, migrations refer to processes used to modify the structure or format of data in your database.

Types of Migrations :-

Up Migration:

  • This is the forward migration that applies changes to the database to achieve a desired state.
  • Examples include adding new fields, creating indexes, renaming collections, or transforming data.
  • It’s typically used to implement new features or adapt to updated application requirements.

Down Migration:

  • This is the rollback migration that undoes the changes made by the up migration.
  • Examples include removing fields, reverting indexes, or restoring data to its original format.
  • It’s useful for reverting the database to its previous state if something goes wrong.

Technology Stack Used :

  • BackEnd : NodeJS, Express
  • Database : Mongodb
  • NPM Package : migrate-mongo

Usage

  1. Clone and navigate to this project directory

  2. Install the dependencies

    npm install
  3. Create sample env file and change configuration according to your need in ".env" file and create Database

  4. Run the node/express server

    npm run start
  5. Open the url http://localhost:<PORT> in browser for seeing the result

  6. Initialize Migrations:

    migrate-mongo init
    
  7. Create a Migration File:

    migrate-mongo create add-new-field
    
  8. Edit the Migration File: Open the migration file and define the up and down operations.

  9. Run the up Migration:

    npx migrate-mongo up
    
  10. Rollback (Run the down Migration):

    npx migrate-mongo down
    

About

⚙️ Migration System with Node.js, Express, and MongoDB 🛠️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published