markNextChangeSetRan command

The markNextChangeSetRan command marks the next change you apply as executed in your database.

Uses

The markNextChangeSetRan command is typically used when you have made a change manually, and the deployment is failing. Here is a use case that shows the whole process in more detail:

  • You have a changelog with a specific changeset and want to create a table in your database, and then apply your changes manually without using Liquibase. In this case, there will be no record of this change in the DATABASECHANGELOG table.
  • Then you decide to deploy the same changeset by using the update command, Liquibase checks the DATABASECHANGELOG table to see if there is such a changeset. Since there is no record of it, Liquibase tries to create a table, but as it already exists, you receive an error.
  • As a result, Liquibase stops deployment at that specific changeset without executing it.
  • Running the markNextChangeSetRan adds that changeset in the changelog as a record even though the table is already created. The command detects that the changeset was deployed.

Additionally, the best practice is to run the markNextChangeSetRanSQL helper command to inspect the markNextChangeSetRan SQL, so you can correct any issues that may arise before running the command.

Running the markNextChangeSetRan command

To run the markNextChangeSetRan command, you need to specify your driver, class path, URL, and user authentication information in your liquibase.properties file. You can also specify these properties in your command line.

Then run the markNextChangeSetRan command:

liquibase --changeLogFile=myChangelog.xml markNextChangeSetRan

Note: Enter the name of the changelog in place of myChangelog.xml.

markNextChangeSetRan global attributes

Attribute Definition Requirement

--changeLogFile

The root changelog

Required

--url

The JDBC database connection URL

Required

--username

The database username

Required

--password

The database password

Required