Skip to content

mongodb-developer/migrate-to-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Migrate to MongoDB - A hands-on workshop

Introduction

This hands-on lab guides you through the process of migrating a legacy application from a relational database to MongoDB. The existing application has an API based on a relational database management system (RDBMS). Our goal is to create a version 2 (v2) of this API that can read the same data using MongoDB instead.

By completing this lab, you'll learn how to:

  1. Set up a MongoDB Atlas cluster
  2. Use a Docker container for the migration process
  3. Migrate data from an RDBMS to MongoDB
  4. Build MongoDB queries for the new API v2

Prerequisites

Before starting this lab, ensure you have the following:

  1. Docker Desktop or Docker Rancher installed on your machine
    • You should be able to pull and run Docker containers
  2. A MongoDB Atlas account

Steps

1. Create a MongoDB Atlas Free Cluster

  1. Log in to your MongoDB Atlas account and create a new free cluster.

  2. Whitelist your IP address:

    • In the Atlas dashboard, go to Network Access
    • Add a new IP address
    • Enter 0.0.0.0 to allow access from anywhere (Note: This is not recommended for production environments)
  3. Create a database user:

    • In the Atlas dashboard, go to Database Access
    • Add a new database user with read and write privileges

2. Pull and Run the Docker Image

Open a terminal and run the following commands:

docker pull [your-image-name]
docker run -it [your-image-name]

Replace [your-image-name] with the actual name of your Docker image.

3. Launch the Migrator

  1. Connect to the RDBMS:

    • Use the provided credentials to connect to your legacy relational database
  2. Connect to MongoDB Atlas:

    • Use the connection string from your Atlas cluster to connect to MongoDB
  3. Map tables to documents:

    • Start with an Empty Schema
    • Design your MongoDB Documents
    • Run the migration process

4. Build MongoDB Queries for API v2

With your data now in MongoDB, you can start building queries for your new API v2:

  • Identify the key operations from your v1 API
  • Translate SQL queries to MongoDB queries
  • Test and optimize your new MongoDB-based API endpoints

Congratulations! You've successfully migrated your data from a relational database to MongoDB and prepared for the new version of your API.

About

A hands-on lab to migrate an app from RDBMS to MongoB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published