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

前端 未结 4 1838
庸人自扰
庸人自扰 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: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 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 element.

    For reference, my changelog-master.xml just consists of elements like

    
    

提交回复
热议问题