1

我真的停留在从Oracle-Base获取的最简单的 liquibase 迁移示例上。所以我创建了两个文件并将其放入文件夹preset中。

文件内容controller.xml

<?xml version="1.0" encoding="UTF-8"?> 
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
    <changeSet author="tim" id="01_tab1_seq">
      <sqlFile dbms="oracle"
               endDelimiter=";"
               path="test.sql"
               splitStatements="true"
               relativeToChangelogFile="true"
               stripComments="false"/>
    </changeSet>
</databaseChangeLog> 

文件内容test.sql

create or replace view asdas
as
select 1 val from dual
/

我在此文件夹中打开 Windows Terminal Preview 并尝试执行迁移:

PS C:\Users\%USERNAME%\Desktop\preset> sql testuser/testuser@dev-db1
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en

SQLcl: Release 21.1 Production on Tue Jul 20 18:25:55 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Last Successful login time: Tue Jul 20 2021 18:25:57 +03:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0


SQL> lb update -changelog controller.xml

Processing has failed for your request.
liquibase.exception.UnexpectedLiquibaseException: java.io.IOException: The file test.sql was not found in
    - C:\Oracle\jdbc\lib\ojdbc8.jar
    - C:\Oracle\jlib\orai18n-mapping.jar
    - C:\Oracle\jlib\orai18n-utility.jar
    - C:\Oracle\jlib\orai18n.jar
    - C:\Oracle\lib\ojdbc8.jar
    - C:\Oracle\modules\oracle.xdk\xmlparserv2.jar
    - C:\Oracle\modules\org.glassfish.javax.json.jar
    - C:\Oracle\rdbms\jlib\xdb6.jar
    - C:\Oracle\sqlcl\lib
    - C:\Oracle\sqlcl\lib\ST4.jar
    - C:\Oracle\sqlcl\lib\antlr-runtime.jar
    - C:\Oracle\sqlcl\lib\commons-codec.jar
    - C:\Oracle\sqlcl\lib\commons-logging.jar
    - C:\Oracle\sqlcl\lib\dbtools-common.jar
    - C:\Oracle\sqlcl\lib\dbtools-data.jar
    - C:\Oracle\sqlcl\lib\dbtools-http.jar
    - C:\Oracle\sqlcl\lib\dbtools-net.jar
    - C:\Oracle\sqlcl\lib\dbtools-sqlcl.jar
    - C:\Oracle\sqlcl\lib\ext
    - C:\Oracle\sqlcl\lib\ext\dbtools-liquibase.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-cli-ext.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-common.jar
    - C:\Oracle\sqlcl\lib\ext\liquibase-core.jar
    - C:\Oracle\sqlcl\lib\ext\snakeyaml-1.12.jar
    - C:\Oracle\sqlcl\lib\guava.jar
    - C:\Oracle\sqlcl\lib\httpclient5.jar
    - C:\Oracle\sqlcl\lib\httpcore5.jar
    - C:\Oracle\sqlcl\lib\httpmime.jar
    - C:\Oracle\sqlcl\lib\jackson-annotations.jar
    - C:\Oracle\sqlcl\lib\jackson-core.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-objects.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-stree.jar
    - C:\Oracle\sqlcl\lib\jansi.jar
    - C:\Oracle\sqlcl\lib\javax.json.jar
    - C:\Oracle\sqlcl\lib\jdbcrest.jar
    - C:\Oracle\sqlcl\lib\jline.jar
    - C:\Oracle\sqlcl\lib\ojdbc8.jar
    - C:\Oracle\sqlcl\lib\oraclepki.jar
    - C:\Oracle\sqlcl\lib\orai18n-collation.jar
    - C:\Oracle\sqlcl\lib\orai18n-mapping.jar
    - C:\Oracle\sqlcl\lib\orai18n-servlet.jar
    - C:\Oracle\sqlcl\lib\orai18n-utility.jar
    - C:\Oracle\sqlcl\lib\orai18n.jar
    - C:\Oracle\sqlcl\lib\orajsoda.jar
    - C:\Oracle\sqlcl\lib\osdt_cert.jar
    - C:\Oracle\sqlcl\lib\osdt_core.jar
    - C:\Oracle\sqlcl\lib\slf4j-api.jar
    - C:\Oracle\sqlcl\lib\slf4j-jdk14.jar
    - C:\Oracle\sqlcl\lib\sshd-common.jar
    - C:\Oracle\sqlcl\lib\sshd-contrib.jar
    - C:\Oracle\sqlcl\lib\sshd-core.jar
    - C:\Oracle\sqlcl\lib\xdb6.jar
    - C:\Oracle\sqlcl\lib\xmlparserv2-sans-jaxp-services.jar
    - C:\Oracle\sqlcl\lib\xmlparserv2.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\access-bridge-64.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\cldrdata.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\dnsns.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\jaccess.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\jfxrt.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\localedata.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\nashorn.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\sunec.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\sunjce_provider.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\sunmscapi.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\sunpkcs11.jar
    - C:\Program Files\Java\jre1.8.0_291\lib\ext\zipfs.jar
    - C:\Users\%USERNAME%\Desktop\preset\ST4-4.3.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\antlr-runtime-3.5.2.jar
    - C:\Users\%USERNAME%\Desktop\preset\commons-codec-1.15.jar
    - C:\Users\%USERNAME%\Desktop\preset\commons-logging-1.2.0.0.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\dbtools-common-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\dbtools-data-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\dbtools-http-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\dbtools-net-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\dbtools-sqlcl-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\guava-30.1-jre.jar
    - C:\Users\%USERNAME%\Desktop\preset\httpclient5-5.0.3.jar
    - C:\Users\%USERNAME%\Desktop\preset\httpcore5-5.0.3.jar
    - C:\Users\%USERNAME%\Desktop\preset\jackson-annotations-2.12.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\jackson-core-2.12.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\jackson-jr-objects-2.12.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\jackson-jr-stree-2.12.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\jansi-1.18.jar
    - C:\Users\%USERNAME%\Desktop\preset\javax.activation-api-1.2.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\javax.json-1.1.4.jar
    - C:\Users\%USERNAME%\Desktop\preset\jaxb-api-2.4.0-b180830.0359.jar
    - C:\Users\%USERNAME%\Desktop\preset\jdbcrest-21.1.1.jar
    - C:\Users\%USERNAME%\Desktop\preset\jline-2.14.6.jar
    - C:\Users\%USERNAME%\Desktop\preset\low-level-api-13.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\ojdbc8-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\oraclepki-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\orai18n-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\orai18n-mapping-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\orai18n-utility-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\orajsoda-1.1.6.jar
    - C:\Users\%USERNAME%\Desktop\preset\osdt_cert-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\osdt_core-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\slf4j-api-1.7.30.jar
    - C:\Users\%USERNAME%\Desktop\preset\slf4j-jdk14-1.7.30.jar
    - C:\Users\%USERNAME%\Desktop\preset\sshd-common-2.6.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\sshd-contrib-2.6.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\sshd-core-2.6.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\sshd-scp-2.6.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\sshd-sftp-2.6.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\ucp-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\xdb6-21.0.0.jar
    - C:\Users\%USERNAME%\Desktop\preset\xmlparserv2-sans-jaxp-services-21.0.0.jar
    - C:\jdbc\lib\ojdbc8.jar
    - C:\jlib\orai18n-mapping.jar
    - C:\jlib\orai18n-utility.jar
    - C:\jlib\orai18n.jar
    - C:\rdbms\jlib\xdb6.jar
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.

即使我sqlcl从同一个目录运行,我也会收到上面的错误。可以看到该目录C:\Users\%USERNAME%\Desktop\preset\不在列表中。相反,有一堆jar文件不会保留在此目录中。

我的操作系统版本是 Windows 10。这是我使用的工具版本:

PS C:\Users\%USERNAME%\Desktop\preset> sql testuser/testuser@dev-db1
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en

SQLcl: Release 21.1 Production on Tue Jul 20 18:35:55 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Last Successful login time: Tue Jul 20 2021 18:35:57 +03:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0


SQL> lb version


Liquibase version:   4.3.1
Extension Version:   21.1.1.0

任何想法将不胜感激。

编辑:

我尝试使用 Windows 10 Linux 子系统运行它并且它有效:

roman@UBUNTU-LT:/mnt/c/Users/%USERNAME%/Desktop/preset$ sql testuser/testuser@dev-db1

SQLcl: Release 21.1 Production on Thu Jul 22 16:54:14 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Last Successful login time: Thu Jul 22 2021 16:54:18 +03:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0


SQL> lb update -changelog controller.xml

######## ERROR SUMMARY ##################
Errors encountered:0

SQL>

看起来在 Windows 环境下运行它有些东西。

4

0 回答 0