liquibase: Inconsistent changelog filename after updating to 4.3.1
Environment
Liquibase Version: 3.10.2 -> 4.3.1 Liquibase Integration & Version: Spring Boot 2.4.3 Liquibase Extension(s) & Version: - Database Vendor & Version: AWS Aurora Operating System Type & Version: -
Description
After upgrading Liquibase from version 3.10.2 to 4.3.1, the logic of calculating the FILENAME column value of each changelog in the DATABASECHANGELOG table is different. Because the filename is a part of the changelog’s identifier, this causes all of the previously executed changelogs to run again.
Before the update, there were some entries in the DATABASECHANGELOG table that looked like so:
ID,AUTHOR,FILENAME
id1,author,db/changelog/changesets/1.yaml
id2,author,db/changelog/changesets/2.yaml
After the update, these changelogs were executed again, adding new DATABASECHANGELOG entries. This is the result:
ID,AUTHOR,FILENAME
id1,author,db/changelog/changesets/1.yaml
id2,author,db/changelog/changesets/2.yaml
id1,author,BOOT-INF/classes/db/changelog/changesets/1.yaml
id2,author,BOOT-INF/classes/db/changelog/changesets/2.yaml
Steps To Reproduce
- Use
db.changelog-master.yaml
with content:
databaseChangeLog:
- includeAll:
path: db/changelog/changesets
- Use Liquibase 3.10.2
- Create a Spring Boot JAR file and run it
- Changelogs are executed for the first time
- Upgrade to Liquibase 4.3.1
- Re-create the Spring Boot JAR and run it again
- Previously executed changelogs are executed for the second time
Actual Behavior
Changelogs which have been previously executed are executed again.
Expected/Desired Behavior
None of the previously executed changelogs are executed again.
Screenshots (if appropriate)
Parts of the DATABASECHANGELOG table content after running Liquibase 4.3.1 (notice the same MD5 sum for the first and last four changelogs - those are the changelogs that have been executed again):
┆Issue is synchronized with this Jira Story by Unito
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 8
- Comments: 15 (5 by maintainers)
I found work around for this issue. I got this fixed by doing the following change to db.changelog-master.yaml
Changed from:
databaseChangeLog: - includeAll: path: db/migration
Changed to:
databaseChangeLog: - include: file: db/migration/V1_0_0__baseline.sql
Basically, used “include-file” option rather than “includeAll-path”
Thanks Vinod Goud
Hi @nvoxland, we are having a simular issue after upgrading from Spring boot 2.4.6 (liquibase-core 3.10.3) to Spring boot 2.5.0 (liquibase-core 4.3.5). Liquibase is trying to run script files that have already been applied resulting in errors like
table already exists
.Our problem is when running on Pivotal Tanzu the application jar-file is extracted by the java buildpack and the changelog is then located in a directory called something like
/vcap/app/BOOT-INF/classes/db/changelog
.Because of this
SpringResourceAccessor
from the new Liquibase version will return file paths likeBOOT-INF/classes/db/changelog/changes/V0001__initial_setup.sql
instead ofdb/changelog/changes/V0001__initial_setup.sql
returned by the old Liquibase version. Liquibase is regarding all changelog files as new files and will try te apply them.It has worked for me but not with the META-INF/MANIFEST.MF file. I registered the custom ChangeLogParser with the file META-INF/services/liquibase.parser.ChangeLogParser containing the full class name of my implementation :
com.exemple.project.auth.util.liquibase.PathFixerLiquibaseChangeLogParser
Here is another workaround. It works with
includeAll