Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase - Error : relation "databasechangelog" already exists

Tags:

liquibase

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..

like image 829
rvini Avatar asked Apr 28 '14 07:04

rvini


2 Answers

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;

like image 157
mfe Avatar answered Sep 17 '22 11:09

mfe


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;
like image 27
Tomasz Avatar answered Sep 21 '22 11:09

Tomasz