Deepak
Deepak

Reputation: 105

Issues with using Liquibase on RedShift database

I have been trying to use this(https://github.com/liquibase/liquibase-redshift/releases) plugin for my Redshift database but haven't been able to get it to work. I am primarily facing two issues.

  1. Invalid operation: syntax error at or near "TAG". I got around this issue by creating the databasechangelog table manually.
  2. Getting an error while inserting the record into the databasechangelog table, due to now() function being used by LB in the insert query.

I see that both the issues have been marked as fixed(https://github.com/liquibase/liquibase-redshift/issues/9) ,however, i am still facing these issues. I cannot make any change manually in the jar files due to the nature of my project. Hence, would appreciate if somebody could provide any insights into this. I am also using dbms="redshift" in my changelog.xml file.

Thank you in advance for any help.

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>

My changeset (app-code.sql) present at 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>```


Upvotes: 0

Views: 1309

Answers (1)

sudo
sudo

Reputation: 775

In your changelog.xml it is dbms="RedshiftDatabase" - it should be 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>

Since it is wrongly specified the RedshiftDatabase won't be used.

Upvotes: 0

Related Questions