unexpected-changesets command produces a list of changesets that were run in the database but do not exist in the current changelog.
unexpected-changesets command is typically used to detect and compare the changes between the DATABASECHANGELOG table and the current changelog. If any of the changesets in the DATABASECHANGELOG table do not exist in the current changelog, the
unexpected-changesets command will detect those changesets and produce them in your output.
unexpected-changesets command also produces all the changesets that were previously deployed and deleted from your current changelog.
The following image shows the changelog file, which includes changesets for
release 1 that are already applied to the database but removed from the changelog file and new changesets for
release 2 that are not applied to the database. Running the
unexpected-changesets command will produce the number of changesets applied for
So, if you want to identifying unexpected changesets that were previously applied to the database, run the
To run the
unexpected-changesets command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Specifying Properties in a Connection Profile. You can also specify these properties in your command line.
Then run the
liquibase --changelog-file=changelog.xml unexpected-changesets
Note: Enter the name of the changelog you want to use in place of
changelog.xml. You can also specify the changelog file in the properties file. The output shows the number of unexpected changesets.
To see the list of unexpected
changesets, add the
--verbose flag while running the command:
liquibase --changelog-file=changelog.xml unexpected-changesets --verbose
unexpected-changesets global attributes
Tip: All commands and parameters use the
--kebab-case format in the CLI environment. This is the format Liquibase recommends for best results. If your preference is camelCase, it will still work in the CLI.
||The root changelog||Required|
||The JDBC database connection URL||Required|
||The database username||Required|
||The database password||Required|
password attributes are not required for connections and systems which use alternate means of authentication.
When running the
unexpected-changesets command with the
--verbose flag, the output can be as follows:
Liquibase Version: 4.9.1 Liquibase Community 4.9.1 by Liquibase 1 unexpected changes were found in DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev liquibase-internal::1652108822075::liquibase Liquibase command 'unexpected-changesets' was executed successfully.
When running the
unexpected-changesets command without indicating the
--verbose flag, you receive the following output:
Liquibase Version: 4.9.1 Liquibase Community 4.9.1 by Liquibase 1 unexpected changes were found in DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev Liquibase command 'unexpected-changesets' was executed successfully.