One of my changesets had a logicalFilePath which was incorrect(two changesets accidentally had the same logicalFilePath) and upon editing the logicalFilePath in an existing chan
How does it work:
From Liquibase docs:
logicalFilePath
- Use to override the file name and path when creating the unique identifier of change sets. Required when moving or renaming change logs.
Liquibase calculates the MD5 checksum of the changeSet based on the:
logicalFilePath
;If you don't change anything in your changeSet and just try to rerun it, Liquibase will look at databasechangelog.id
, databasechangelog.author
, databasechangelog.FILENAME
and databasechangelog.MD5SUM
, and if everything is the same as it was, then the changeSet will be skipped.
If you change the content of the changeSet, liquibase will throw an error that checksum was changed (while databasechangelog.id
, databasechangelog.author
and databasechangelog.FILENAME
stays the same).
If you change the id, author or path (logicalFilePath), then Liquibase will think that it's a new changeSet and will try to execute it.
Why do you have a problem:
Liquibase treats you changeSet as new, and as you have an error:
update failed with an error of duplicate column
I suppose you don't have any preConditions
in your changeSet or they aren't sufficient enough,
How do you fix it:
So since liquibase thinks that you're executing a new changeSet, nothing stops you from writing those:
and because your_table.your_column
already exists in the database, then this changeSet will be marked as databasechangelog.EXECTYPE=MARK_RAN
and skipped.
Problem solved!