How to configure liquibase not to include file pat

2019-02-12 08:32发布

问题:

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.

回答1:

Use the attribute logicalFilePath of the databaseChangeLog tag.



回答2:

Upstream developers recommend use logicalFilePath and suggest to perform direct update on DATABASECHANGELOG.FILENAME column:

  • http://forum.liquibase.org/topic/why-does-the-change-log-contain-the-file-name

to fix broken entries with full paths.

If you set hashes DATABASECHANGELOG.MD5SUM ot null that trigger hashes recalculation on next LiquiBase run. You should do this because hash algorithm uses all compound ID parts when calculated.



回答3:

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"/>


标签: liquibase