Ошибка Liquibase: liquibase.precondition.core.SequenceExistsPrecondition Пустой набор результатов, ожидается одна строка - PullRequest
0 голосов
/ 30 апреля 2020

Я получаю ошибку ликвидазы с этим набором изменений:

<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

Db Версия: PostgreSQL 11.7 (Ubuntu 11.7-2.pgdg18.04 + 1)

1 Ответ

0 голосов
/ 30 апреля 2020

Неважно, я только что обновил свою 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>
...