使用maven和postgres-db运行liquibase的问题

时间:2011-02-14 17:40:59

标签: database postgresql maven liquibase

我在postgresql-db上运行maven的liquibase-plugin时遇到问题。 当尝试运行liquibase:从命令行更新时,我收到错误消息

[ERROR] Failed to execute goal org.liquibase:liquibase-plugin:1.9.5.0:update (de
fault-cli) on project backend-persistence: Error setting up or running Liquibase
: liquibase.exception.JDBCException: Error executing SQL CREATE TABLE databasech
angeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WIT
H TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY
KEY (ID)): FEHLER: Relation ╗databasechangeloglock½ existiert bereits -> [Help 1
]

简单地删除db-table没有帮助,看起来liquibase正在创建它两次,如日志文件建议的那样:

...
CREATE TABLE databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITH TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))
COMMIT
BEGIN
INSERT INTO databasechangeloglock (ID, LOCKED) VALUES (1, false)
COMMIT
BEGIN
LECT NULL AS TABLE_CAT, n.nspname AS TABLE_SCHEM, c.relname AS TABLE_NAME,  CASE n.nspname 

....
CREATE TABLE databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITH TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))
FEHLER:  Relation »databasechangeloglock« existiert bereits (already exists)

任何想法如何解决这个问题?

提前致谢,

的Matthias

2 个答案:

答案 0 :(得分:1)

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.0-beta-9</version>
        </plugin>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-plugin</artifactId>
            <version>1.9.5.0</version>
            <configuration>
                <propertyFile>${liquibase.propertyFile}</propertyFile>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>9.0-801.jdbc4</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

答案 1 :(得分:1)

您的postgres数据库中可能有多个架构。要解决您的问题,请在公共架构中移动所有数据。