Using Liquibase MongoDB Pro with MongoDB Platforms
MongoDB is a NoSQL (non-relational) database. MongoDB Pro provides the ability to work with native mongosh scripts.
You can use Liquibase with several MongoDB providers, including MongoDB Atlas, MongoDB Community Server, MongoDB Enterprise Server, and the Amazon DocumentDB clone. The Liquibase MongoDB Pro extension lets you use all the features of Liquibase Pro with MongoDB, including Quality Checks, Secrets Management, and Structured Logging. These features enhance your database's security, reliability, and compatibility with other tools in your development pipeline.
Using Liquibase with MongoDB is similar to using it with other databases. You still track changes within changesets in changelogs, and use commands such as
rollback to deploy changes and manage your database. However, because MongoDB does not use SQL, you cannot use SQL changelogs or Liquibase commands that generate SQL output.
You can write Liquibase changelogs in the MongoDB Pro extension in three ways:
- Native MongoDB Shell (
- Formatted Mongo changelogs (MongoDB Pro 1.3.0+) – Add Liquibase changeset metadata to your
mongoshscripts to use features like rollback, contexts, labels, and the
- XML, YAML, and JSON modeled changelogs – Specify
mongoshscripts using the
mongoFileChange Types and create root changelogs to use
To learn how to specify changes in each format, see Using mongosh in Your Changelog.
Getting started tutorials
To learn how to configure the Liquibase MongoDB Pro extension with your installation of MongoDB, see the following topics:
- Using Liquibase MongoDB Pro with MongoDB Atlas – Multi-cloud database service to manage databases on demand
- Using Liquibase MongoDB Pro with MongoDB Community and Enterprise Server – Fully-featured MongoDB products for small or large-scale development
- Using Liquibase MongoDB Pro with Amazon DocumentDB – Use MongoDB functionality through a clone, Amazon DocumentDB
Tip: To use the community-maintained Liquibase MongoDB extension, see Contributors Docs: MongoDB Extension.
The MongoDB Pro extension supports all the features of Liquibase that are supported in the MongoDB Open Source extension. In addition, MongoDB Pro lets you use Liquibase Pro features including:
- Quality Checks – Automatically analyze your changelogs for desired format and behavior to increase deployment success rates and uphold security best practices
- Secrets Management – Keep your authentication data secure by integrating with third-party secrets vaults
- Structured Logging – Improve your database observability by easily reading Liquibase data in your favorite analytics tool
- Flow Files – Create repeatable, portable, and platform-independent Liquibase workflows to run in any of your CI/CD tools
- Feature Flags – Define and control when database changes are applied
- Remote file access – Centralize file management with AWS S3 to build a reusable repository of Liquibase files you can update and retrieve
- Targeted rollback – Avoid collateral damage by specifying which changesets in your changelog to undo
You can use all the standard Liquibase Change Types in MongoDB Pro. The two new Change Types available are
mongoFile, which allow you to specify native Mongo scripts in XML, YAML, and JSON changelogs. They require the user to configure the native executor, Mongo Shell (
mongosh), prior to use.
MongoDB supports the following commands:
- Update commands, except those that generate SQL output. For example,
- Rollback commands, except those that generate SQL output. For example,
- Change tracking commands, except those that generate SQL output. For example,
- Quality checks commands. For example,
- All other commands, unless otherwise specified in the Limitations section.
For more information, see About Liquibase Commands.
Supported quality checks
You can use changelog-scoped quality checks in MongoDB Pro. For example:
- Checks that focus on changeset metadata, such as RollbackRequired and ChangesetLabelCheck.
- The generic regex-based check SqlUserDefinedPatternCheck.
Note: These quality checks only work if you have created your own from the regex template. Liquibase uses the java.util.regex engine to match regular expressions.
Changelog-scoped quality checks are supported as long as they are not SQL-specific or relational-specific. The following is a full list of quality checks supported on MongoDB:
- The child MongoDB scripts referenced by the
includeAlltags must contain the changeset decoration and the following minimum changeset metadata,
// liquibase formatted mongodb
// changeset authorname:1 runWith:mongosh
modifyChangeSets tag is not supported.
changelog-sync-sql). MongoDB also does not support the database inspection command family (such as
generate-changelog). Learn more about About Liquibase Commands here.
|Liquibase MongoDB Pro
|Liquibase Pro version required
|MongoDB versions verified
|MongoDB Shell versions verified
- MongoDB Pro and Amazon DocumentDB TLS/SSL Configuration
- Configuring User Roles for MongoDB Pro