How to configure liquibase not to include file path or name for calculating checksum?

前端 未结 4 1860
庸人自扰
庸人自扰 2021-01-04 05:25

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 rea

相关标签:
4条回答
  • 2021-01-04 05:39

    Use the attribute logicalFilePath of the databaseChangeLog tag.

    0 讨论(0)
  • 2021-01-04 05:55

    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

    0 讨论(0)
  • 2021-01-04 05:56

    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"/>
    
    0 讨论(0)
  • 2021-01-04 05:57

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

    • https://forum.liquibase.org/t/why-does-the-change-log-contain-the-file-name/481

    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.

    0 讨论(0)
提交回复
热议问题