【问题标题】:Issues with using Liquibase on RedShift database在 RedShift 数据库上使用 Liquibase 的问题
【发布时间】:2020-07-07 15:23:50
【问题描述】:

我一直在尝试为我的 Redshift 数据库使用这个 (https://github.com/liquibase/liquibase-redshift/releases) 插件,但无法让它工作。我主要面临两个问题。

  1. 无效操作:“TAG”处或附近的语法错误。我通过手动创建 databasechangelog 表解决了这个问题。
  2. 将记录插入数据库更改日志表时出错,原因是 LB 在插入查询中使用了 now() 函数。

我看到这两个问题都被标记为已修复(https://github.com/liquibase/liquibase-redshift/issues/9),但是我仍然面临这些问题。由于我的项目的性质,我无法在 jar 文件中手动进行任何更改。因此,如果有人可以对此提供任何见解,将不胜感激。我也在我的 changelog.xml 文件中使用dbms="redshift"

提前感谢您的帮助。

Changelog.xml

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
    <changeSet author="devsh0" id="9.9.9.9" logicalFilePath="LOGICALPATH" runOnChange ="true" >
         <sqlFile 
            path="src/main/dbo/app-code.SQL"
            dbms="RedshiftDatabase"
            stripComments="true"
        />
    </changeSet>
</databaseChangeLog>

我的变更集(app-code.sql) 出现在src/main/dbo/

create table Test_Table
(
  col1   VARCHAR(3) not null,
  col2   VARCHAR(20) not null,
  col3   VARCHAR(50) not null
)

POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>local_redshift</groupId>
  <artifactId>local_redshift</artifactId>
  <version>0.0.1-SNAPSHOT</version>
<repositories>
    <repository>
      <id>redshift</id>
      <url>https://s3.amazonaws.com/redshift-maven-repository/release</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
        <version>3.10.0</version>
    </dependency>
    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc42</artifactId>
       <version>1.2.43.1067</version>
    </dependency>
    <dependency>
        <groupId>org.liquibase.ext</groupId>
        <artifactId>liquibase-redshift</artifactId>
        <version>3.10.0</version>
    </dependency>
    <!--dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>1.8</version>
    </dependency>  -->
</dependencies>
 <build>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.4.2</version>
                <configuration>
                   <propertyFile>src/main/liquibase.redshift.properties</propertyFile>
                   <changeLogFile>src/main/changelog/changelog-1.0.0.0.1.xml</changeLogFile>
                  <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>```


【问题讨论】:

  • dbms 设置不正确,否则会 GETDATE() - 你能分享你的变更日志和变更集吗?
  • @sudo 我已经添加了变更日志和变更集。我试过用 dbms="RedshiftDatabase" 和 dbms="redshift" 和 dbms="redshiftdatabase" 运行它,但到目前为止没有任何效果。

标签: amazon-redshift devops maven-plugin pipeline liquibase


【解决方案1】:

在您的 changelog.xml 中,它是 dbms="RedshiftDatabase" - 它应该是 dbms="redshift"

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
    <changeSet author="devsh0" id="9.9.9.9" logicalFilePath="LOGICALPATH" runOnChange ="true" >
         <sqlFile 
            path="src/main/dbo/app-code.SQL"
            dbms="redshift"
            stripComments="true"
        />
    </changeSet>
</databaseChangeLog>

由于指定错误,RedshiftDatabase 将不会被使用。

【讨论】:

  • 正如我在描述和上面的评论中提到的,我也尝试了带有 dbms="redshift" 的 changelog.xml,但它没有奏效。你认为我还缺少什么吗?
猜你喜欢
  • 2017-06-09
  • 2013-05-03
  • 2022-01-24
  • 2018-04-01
  • 2014-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-05
相关资源
最近更新 更多