Question

I'm trying to integrate liquibase with our application. I'm executing it using Maven integration approach.

When I execute, I see that creation script for databasechangelog invoked twice and get "Table already exist" error. Below are the statements from console. I'm using liquibase-core-3.1.1 jar.

INFO 2014-04-28 06:49:liquibase: Successfully acquired change log lock
INFO 2014-04-28 06:49:liquibase: Creating database history table with name: databasechangelog
INFO 2014-04-28 06:49:liquibase: ChangeSet src/main/resources/sql/postGre/db.changelog-2.0.xml::1::fms ran successfully in 555ms
INFO 2014-04-28 06:49:liquibase: Creating database history table with name: databasechangelog
SEVERE 2014-04-28 06:49:liquibase: Error executing SQL CREATE TABLE databasechangelog (ID VARCHAR(63) NOT NULL, AUTHOR VARCHAR(63) NOT NULL, FILENAME VARCHAR(200) NOT NULL, DATEEXECUTED TIMESTAMP WITH TIME ZONE NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONSTRAINT PK_DATABASECHANGELOG PRIMARY KEY (ID, AUTHOR, FILENAME))
org.postgresql.util.PSQLException: ERROR: relation "databasechangelog" already exists

POM file entry

<plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>2.0.1</version>
            <configuration>
                <changeLogFile>src/main/resources/sql/postGre/changelog-master.xml</changeLogFile>
                <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                <defaultschemaName><<my application schema>> </defaultschemaName>
                <driver>org.postgresql.Driver</driver>
                <url>jdbc:<<mydburl>> </url>
                <username>user</username>
                <password>pwd</password>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

please do let me where I'm going wrong..

Was it helpful?

Solution 3

Got this working, we were using older version of posgres, with 9.1 version its accepting defaultSchemaName and its workign now. Thanks for all the suggestions.

OTHER TIPS

for h2 database ı was have the same problem.

my connection string was

jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;

After I removed DATABASE_TO_UPPER=false from the end it starts working.

last connection string as follows:

jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;

Try to add CASE_INSENSITIVE_IDENTIFIERS=TRUE; param to your url connection. Example :

datasource:
    url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE;

Same issue in Mysql database, got resolved after adding the schema name in changelog as below.

<changeSet author="chiran" id="Creation of Static Marker">
    <createTable tableName="STATIC_MARKER2" schemaName="SWIFT">
    <column name="marker_id" type="BIGINT" autoIncrement="true">
        <constraints primaryKey="true" nullable="false" />
    </column>
    <column name="marker_name" type="varchar(50)">
        <constraints nullable="false" />
    </column>
    <column name="refillable" type="BIGINT"></column>
    <column name="created" type="TIMESTAMP"/>
    </createTable>
</changeSet>

And below is the snapshot of maven-liquibase plugin version used.
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.2</version>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top