sqlFile + relativeToChangelogFile fails when using a logicalFilePath
See original GitHub issueEnvironment
Liquibase Version: 4.0.0
Liquibase Integration & Version: CLI
Liquibase Extension(s) & Version:
Database Vendor & Version: SQL SERVER 2019
Operating System Type & Version: WIN 10 Pro 2004 (19041.388)
Description
When a changelog has a ‘logicalFilePath’ set, execution of ‘sqlFile’ changes that have the ‘relativeToChangelogFile’ set to true fail with an IOException that says that the sql file can’t be found in a number of different paths. If ‘logicalFilePath’ is not set, everything works
Steps To Reproduce
- Have a simple XML changelog that has an ‘logicalFilePath’ attribute in the root ‘databaseChangeLog’ node.
- Have inside that changelog a changeset with a ‘sqlFile’ change that points to an existing file in the same folder than the changelog, and that has ‘relativeToChangelogFile=“true”’
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"
logicalFilePath="a-logical-file-path">
<changeSet id="some-changeset" author="NA">
<sqlFile endDelimiter="GO"
path="file.sql"
relativeToChangelogFile="true"
/>
</changeSet>
</databaseChangeLog>
- Run liquibase update against the db
liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --url="jdbc:sqlserver://localhost:1433;database=the_database" --changeLogFile=changelog.xml --username=the_username --password=thepassword --logLevel=debug update
Actual Behavior
Executions fails with an IOException.
Unexpected error running Liquibase: java.io.IOException: The file file.sql was not found in
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\access-bridge-64.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\cldrdata.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\dnsns.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\jaccess.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\localedata.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\nashorn.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\sunec.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\sunjce_provider.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\sunmscapi.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\sunpkcs11.jar
- C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot\jre\lib\ext\zipfs.jar
...
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.
For more information, please use the --logLevel flag
Expected/Desired Behavior
No error happens and the sql file is executed against the database.
Additional Context
- This is happening since 4.0.0 beta1. Version 3.10 works fine
- Peeking a little inside the code, it seems that SQLFileChange.openSqlStream is using the filepath of the changeset (which contains the logicalFilePath) instead of the physical path of the containing changelog (which seems to be the behavior of v 3.x)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:35 (11 by maintainers)
Top Results From Across the Web
sqlFile tag has no relativeToChangelogFile attribute
In this situation we have experience a problem with the sqlFile tags. The program is not able to find the referenced sql file....
Read more >How to configure liquibase not to include file path or name for ...
If we decide we want to rename or move an individual SQL file later on, then we can specify the old value in...
Read more >sqlFile | Liquibase Docs
Reference information for the sqlFile change type. The sqlFile change type allows you to specify any sql statements and have it stored external...
Read more >changelog.txt - AlisonSouza/liquibase - Gitiles - GerritHub.io
[CORE-1343] - Include SQL file with relativeToChangelogFile doesn't work. - [CORE-1378] - Deploy fails on Glassfish. - [CORE-1409] - Package CDI support as ......
Read more >changelog.txt · xiaowu/liquibase-3.10.2 - Gitee.com
- Fixed an 'Unexpected type: java.util.Date' error when using a defaultValueDate attribute in a YAML changelog. Changes in version 3.8.3 (2019.12.19).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The bug is still effective on 4.6.1
Hi! We are really blocked by the same issue and can’t upgrade liquibase to 4.x.x from 3.5.x. When you are going to release a patch with this fix? Thanks!