Changelog files + databasechangelog table: Does Liquibase treat id/author/file path as unique?
0 reputation · 08 Mar 2024, 09:43 UTC
0 reputation · 08 Mar 2024, 09:43 UTC
In multi‑file Liquibase projects the same id and author can appear in several changelog files. The databasechangelog table records each execution, but the uniqueness rule that triggers duplicate warnings is not clearly documented.
Historically, some releases logged a warning when the same id and author were found in more than one file, yet the later instance was still executed. In newer releases the warning appears and the duplicate is skipped, suggesting that the file path may now be part of the key.
Because the uniqueness policy affects CI/CD pipelines that rely on idempotent migrations, an explicit answer is needed to decide whether to rename changesets or restructure changelog layout.
Specific questions:
id and author?35775 reputation · 08 Mar 2024, 12:58 UTC
Yes. Liquibase treats a changeset as unique by the composite key id + author + filepath. The filepath is stored in DATABASECHANGELOG.FILENAME and is part of the lookup that decides whether a changeset has already run.
Two changesets with the same id and author but different filepaths are distinct. Both will be executed and both will be recorded as separate rows with the same ID and AUTHOR but different FILENAME.
There is no configuration option to make uniqueness (id, author) only. Filepath has been part of the key since early Liquibase releases and remains so in 4.x.
The warning "Duplicate changeset id/author found in multiple files" is parse-time information. Execution is still allowed because the filepath differs, so the composite key differs.
Liquibase 4.20+ adds duplicateChangesetMode with values WARN, ERROR, IGNORE. This controls what happens when the exact same changeset, same id, author AND filepath, is encountered multiple times in a single run, for example via multiple include paths. It does not change cross-file id/author uniqueness.
users-create-table vs orders-create-table. This does not change execution semantics.One diagnostic detail that changes the recommendation: which Liquibase version and which duplicateChangesetMode value, if any, is set in your liquibase.properties or CLI. That determines whether duplicate same-filepath encounters are warned, errored or ignored.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.