Spring Data - Easy MongoDB Migration Using Mongock

Eric Anicet
7 min readOct 28, 2024

In this story, we’ll learn how to manage and apply MongoDB database schema changes using Mongock.

· Prerequisites
· Overview
What is Mongock?
Why Mongock?
Mongock Architecture
· Let’s get to the code
Add Dependencies
Enable Mongock
Create Migration Classes
· Test the application
· Conclusion
· References

Prerequisites

This is the list of all the prerequisites:

  • Spring Boot 3+
  • Maven 3.6.3
  • Java 21
  • MongoDB instance (v6 or later) installed

Overview

In one of my projects, I was looking for simple options to manage MongoDB database schema changes, similar to those in other projects like Flyway or Liquibase. I found Mongock, an open-source Java MongoDB tool.

What is Mongock?

Mongock is a Java-based migration tool specifically designed to manage database schema changes in MongoDB and other NoSQL…

--

--

No responses yet