MongoDB
Published 27 April 2026
- Verified Versions: V5,V8
- Maintainer: Redgate
Supported Versions and Support Levels
- For information regarding the supported version and support levels available, please see Supported Databases for Flyway
- For information regarding the Flyway features available, please see Flyway feature summary
Terminology
We have to map Flyway concepts and language rooted in the relational database world to MongoDB - this is how Flyway sees the mapping:
| MongoDB Concept | Flyway Concept |
|---|---|
| database | database/schema |
| collection | table |
| document | row |
| transaction | transaction |
Configuration
- Flyway identifies the migration type through the file extension. You should set sqlMigrationSuffixes to
.jsfor JavaScript migrations or.jsonfor JSON migrations.- Note that Flyway doesn't support mixed migration types in a single project
- Any non-credential configuration (see Mongo Connection String Options needs to go into the connection string (Flyway's URL parameter), as this is passed directly to both the driver and Mongosh.
- There is a tutorial available here.
JavaScript migrations
- JavaScript migrations require
mongoshto be installed where Flyway can use it. - To use JavaScript migrations with our official Docker image, you will need to use either the
redgate/flyway:12.11.0-mongo,-alpine-mongoor-azure-mongoimages as these include the Mongosh tool.
Limitations
- JavaScript (
.js) migrations cannot use transactions, which is a limitation of Mongosh. A warning will be displayed ifexecuteInTransactionis set. See this blog post for more details. - You can't currently do a Dry-run operation with MongoDB.
This documentation contains proprietary information and is protected by copyright law.
Copyright © 2026 Red Gate Software Limited. All rights reserved