duplicate-file-mode

The --duplicate-file-mode global parameter specifies how Liquibase handles multiple files being found in the search path that have duplicate paths. Valid values are SILENT (do not log and choose one at random), DEBUG, INFO, WARN (log at the given level and choose one at random), and ERROR (fail current operation). Default: ERROR.

Uses

If you have multiple changelogs containing changesets with the same ID, Liquibase uses the value of the --duplicate-file-mode parameter to determine which changeset to use.

This parameter is useful if you accidentally copy a changeset to another changelog or if multiple developers create changesets with the same IDs without realizing it.

The use-cases for each value are:

  • SILENT: No messages are logged regarding duplicate changesets. Liquibase chooses a random changeset to use. Useful in environments where duplicates are known and accepted, and you want to avoid cluttering logs with duplicate warnings.
  • DEBUG: Provides detailed debug information, including messages about duplicate changesets.Liquibase chooses a random changeset to use. Useful for development or testing environments where developers need in-depth information for troubleshooting or analysis of changeset execution.
  • INFO: Logs informational messages about duplicate changesets but does not halt execution.Liquibase chooses a random changeset to use. Useful for production environments where you want to be notified of duplicates without verbose messages, and you prefer to continue processing.
  • WARN: Issues a warning for each duplicate changeset but continues execution. Liquibase chooses a random changeset to use. Useful if you want to be notified of potential issues without stopping the migration, allowing for careful review later.
  • ERROR: Stops execution and throws an error when a duplicate changeset is encountered. Useful for critical production environments where duplicates can lead to serious issues.

Syntax

You can set this parameter in the following ways:

Option Syntax
Liquibase properties file (defaults file)
liquibase.duplicateFileMode: <string>
Global flow file argument (example)
stages:
  Default:
    actions:
      - type: liquibase
        command: update
        globalArgs: { duplicate-file-mode: "<string>" }
Global CLI parameter
liquibase
 --duplicate-file-mode=<string> update
 --changelog-file=example-changelog.xml

JVM system property (JAVA_OPTS Environment Variable)

JAVA_OPTS=-Dliquibase.duplicateFileMode=<string>
Liquibase Environment Variables
LIQUIBASE_DUPLICATE_FILE_MODE=<string>

For more information, see Working with Command Parameters.

Related links