使用 Maven 和 postgres-db 运行 liquibase 时出现问题

发布于 2024-10-17 11:55:57 字数 1403 浏览 6 评论 0原文

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

[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)

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

预先感谢,

马蒂亚斯

I have a problem running maven's liquibase-plugin on a postgresql-db.
When trying to run liquibase:update from the command-line, I get the error message

[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
]

simply dropping the db-table does not help, it looks like liquibase is creating it twice, as the logfile suggests:

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

Any ideas how to solve this problem?

Thanks in advance,

Matthias

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷爱 2024-10-24 11:55:57
<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>
<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>
快乐很简单 2024-10-24 11:55:57

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

You're probably have multiple schema in your postgres database. To solve your problem, move all your data in the public schema.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文