Reputation: 763
I found that liquibase uses the full path of the change log file to calculate the checksum.
This behavior restricts to modify change log file names and tries to reapply the change sets again once renamed the file.
Is there a way to configure liquibase to use only the changelog id to calculate cuecksum?
Please provide your valuable thoughts.
Upvotes: 18
Views: 26538
Reputation: 48813
Upstream developers recommend to use logicalFilePath
and suggest to perform direct update on DATABASECHANGELOG.FILENAME
column:
to fix broken entries with full paths.
If you set hashes DATABASECHANGELOG.MD5SUM
to null
that triggers hashes recalculation on next LiquiBase run. It is necessary as hash algorithm includes moving parts too into the result.
Upvotes: 6
Reputation: 177
I have faced the same problem and found solution below.
If you are using liquibase sql format
then simply put below in your sql file:
--liquibase formatted sql logicalFilePath:<relative SQL file path like(liquibase/changes.sql)>
If you are using liquibase xml format
then simply put below in your xml file:
<databaseChangeLog logicalFilePath=relative XML file path like(liquibase/changes.xml)" ...>
...
</databaseChangeLog>
After adding above logicalFilePath
attribute, run the liquibase update
command.
It will put relative file path
whatever you put in logicalFilePath
in FILENAME
column of table DATABASECHANGELOG
Upvotes: 5
Reputation: 1387
One really similar issue- you may just want to ignore the portion of the path before the changelog-master.xml
file. In my scenario, I've checked out a project in C:\DEV\workspace
and my colleague has the project checked out in C:\another_folder\TheWorkspace
.
I'd recommend reading through http://forum.liquibase.org/topic/changeset-uniqueness-causing-issues-with-branched-releases-overlapped-changes-not-allowed-in-different-files first.
Like others have suggested, you'll want the logicalFilePath
property set on the <databaseChangeLog>
element.
You'll also need to specify the changeLogFile
property in a certain way when calling liquibase. I'm calling it from the command line. If you specify an absolute or relative path to the changeLogFile
without the classpath, like this, it will include the whole path in the DATABASECHANGELOG table:
liquibase.bat ^
--changeLogFile=C:\DEV\more\folders\schema\changelog-master.xml ^
...
then liquibase will break if you move your migrations to any folder other than that one listed above. To fix it (and ensure that other developers can use whatever workspace location they want), you need to reference the changelogFile
from the classpath:
liquibase.bat ^
--classpath=C:\DEV\more\folders ^
--changeLogFile=schema/changelog-master.xml ^
...
The first way, my DATABASECHANGELOG table had FILENAME values (I might have the slash backwards) like
C:\DEV\more\folders\schema\subfolder\script.sql
The second way, my DATABASECHANGELOG table has FILENAME values like
subfolder/script.sql
I'm content to go with filenames like that. Each developer can run liquibase from whatever folder they want. If we decide we want to rename or move an individual SQL file later on, then we can specify the old value in the logicalFilePath
property of the <changeSet>
element.
For reference, my changelog-master.xml
just consists of elements like
<include file="subfolder/script.sql" relativeToChangelogFile="true"/>
Upvotes: 5