Use native executors with MongoDB Pro
Last updated: July 14, 2025
Before you begin
Use Liquibase 4.20.0 or later.
Add Mongosh to your
PATH
environment variable. Alternatively, pass its location in theliquibase.mongosh.conf
file or from the command prompt during runtime.
Procedure
Add the runWith attribute to the needed changesets in the changelog.
SQL:
runWith:mongosh
XML:
runWith="mongosh"
YAML:
runWith: mongosh
JSON:
"runWith": "mongosh"
Specify the Mongosh integration arguments in one of the following ways.
Pass the values at runtime on the command line.
Add the values to
liquibase.mongosh.conf
or the Liquibase properties file.Set the values as environment variables.
Run the values as Java system properties (
JAVA_OPTS
) along with any command at the command prompt.
Windows
set JAVA_OPTS=-Dliquibase.mongosh.<option>=<value> && liquibase <command> --changelog-file=my_script.js
Linux/macOS
export JAVA_OPTS=-Dliquibase.mongosh.<option>=<value> && liquibase <command> --changelog-file=my_script.js
Run a Liquibase command.
Example: liquibase status --changelog-file=my_script.js
Note: If the command fails, you will receive an error message. However, if you add a property that is not used in Liquibase to the liquibase.mongosh.conf
file, no error occurs. Liquibase only ignores it.