【问题标题】:Liquibase Error: liquibase.precondition.core.SequenceExistsPrecondition Empty result set, expected one rowLiquibase 错误:liquibase.precondition.core.SequenceExistsPrecondition 空结果集,预期一行
【发布时间】:2020-08-14 08:48:57
【问题描述】:

我在使用这个变更集时遇到了一个 liquibase 错误:

<changeSet id="CORE-1" author="system">
    <preConditions onFail="MARK_RAN">
        <not>
            <sequenceExists sequenceName="HIBERNATE_SEQUENCE"/>
        </not>
    </preConditions>
    <comment>Create HIBERNATE_SEQUENCE</comment>
    <createSequence incrementBy="1"
                    sequenceName="HIBERNATE_SEQUENCE"/>
</changeSet>

我的 Maven 配置文件配置:

<profiles>
    <profile>
        <id>buildDatabase</id>
        <activation>
            <property>
                <name>cleandb</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <configuration>
                        <driver>${jdbc.driver}</driver>
                        <url>${jdbc.url}</url>
                        <username>${jdbc.username}</username>
                        <password>${jdbc.password}</password>
                        <outputDefaultSchema>true</outputDefaultSchema>
                        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                        <arguments>-Dliquibase.enableEscaping=true</arguments>
                    </configuration>
                    <executions>
                        <execution>
                            <id>generate-db-public</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>update</goal>
                            </goals>
                            <configuration>
                                <changeLogFile>src/main/resources/db/liquibase-changelog.xml</changeLogFile>
                                <changeLogSchemaName>public</changeLogSchemaName>
                                <defaultSchemaName>public</defaultSchemaName>
                                <dropFirst>false</dropFirst>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.yaml</groupId>
                            <artifactId>snakeyaml</artifactId>
                            <version>${snakeyaml.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>postgresql</groupId>
                            <artifactId>postgresql</artifactId>
                            <version>${postgresql.plugin.jdbc.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>

配置和版本:

<postgresql.plugin.jdbc.version>9.1-901.jdbc4</postgresql.plugin.jdbc.version>
 <jdbc.host>localhost</jdbc.host>
 <jdbc.databaseName>system_db</jdbc.databaseName>
 <jdbc.url>jdbc:postgresql://${jdbc.host}/${jdbc.databaseName}</jdbc.url>
 <jdbc.driver>org.postgresql.Driver</jdbc.driver>
 <jdbc.username>postgres</jdbc.username>
 <jdbc.password>postgres</jdbc.password>

我已经尝试使用已经存在的序列运行它并删除它。 但我收到此错误消息:

Error setting up or running Liquibase:
[ERROR] Migration failed for change set src/main/resources/db/1.0-changelog/1.0-changelog.xml::CORE-1::system:
[ERROR]      Reason: 
[ERROR]           src/main/resources/db/liquibase-changelog.xml : liquibase.precondition.core.SequenceExistsPrecondition@131a7516 : Empty result set, expected one row
[ERROR] : Precondition Error: Error getting jdbc:postgresql://localhost/system_db view with liquibase.statement.core.GetViewDefinitionStatement@59838256: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@1859ffda but got 0

数据库版本: PostgreSQL 11.7 (Ubuntu 11.7-2.pgdg18.04+1)

【问题讨论】:

    标签: liquibase


    【解决方案1】:

    没关系,我刚刚更新了我的 postgreSQL 驱动程序依赖项,它现在可以工作了:

    <dependency>
         <groupId>org.postgresql</groupId>
         <artifactId>postgresql</artifactId>
         <version>${postgresql.plugin.jdbc.version}</version>
    </dependency>
    

    版本是:

    <postgresql.plugin.jdbc.version>42.2.12</postgresql.plugin.jdbc.version>
    

    【讨论】:

      猜你喜欢
      • 2012-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-18
      • 2014-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多