Liquibase diff функциональность - PullRequest
1 голос
/ 20 марта 2020

.. поэтому я прогревался до Liquibase и изо всех сил пытался заставить функционировать liquibase diff . Я надеюсь, что смогу воспользоваться этим форумом, чтобы получить некоторую помощь.

Описание проблемы

У меня есть обновленная база данных Dev с changeset1 и changeset2, в то время как Prod DB обновлен только с changeset1. Используя пользовательский интерфейс SQL, я вижу таблицы, соответствующие changeset1, созданные в Dev и Prod, а таблицы, соответствующие changeset2, отсутствуют в Prod DB. Пока что это в ожидаемых строках.

Однако, когда я выполняю liquibase diff на Prod, ссылаясь на Dev DB, я ожидаю увидеть различия (changeset2). Тем не менее, я не вижу изменений, перечисленных в выходных данных Liquibase - и, следовательно, в этом посте. Где я могу ошибаться?

Обратите внимание, я использую докеризованные экземпляры Oracle, и у меня есть 2 docker -db экземпляров, имитирующих среду Dev и Prod соответственно.

Maven pom. xml

<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.jenkov</groupId>
  <artifactId>hello-world</artifactId>
  <version>1.0.0</version>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.liquibase</groupId>
          <artifactId>liquibase-maven-plugin</artifactId>
          <version>3.8.7</version>
          <dependencies>
            <dependency>
              <groupId>com.oracle</groupId>
              <artifactId>ojdbc14</artifactId>
              <version>10.2.0.4.0</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.8.7</version>
            <configuration>
              <dropFirst>false</dropFirst>
              <propertyFile>src/main/resources/liquibase/liquibase-dev.properties</propertyFile>
            </configuration>
            <executions>
              <execution>
                <phase>compile</phase>
                <goals>
                  <goal>update</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M4</version>
            <configuration>
              <skipTests>false</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>prod</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.8.7</version>
            <configuration>
              <dropFirst>false</dropFirst>
              <propertyFile>src/main/resources/liquibase/liquibase-prod.properties</propertyFile>
            </configuration>
            <executions>
              <execution>
                <phase>compile</phase>
                <goals>
                  <goal>update</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M4</version>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

liquibase-dev.properties

changeLogFile: src\/main\/resources\/liquibase\/dbchangelog.xml
url: jdbc:oracle:thin:@localhost:1521/xe
username: system
password:
verbose: true
referenceUrl: jdbc:oracle:thin:@localhost:1521/xe
referenceUsername: system
referencePassword:

liquibase-prod.properties

changeLogFile: src\/main\/resources\/liquibase\/dbchangelog.xml
url: jdbc:oracle:thin:@localhost:1523/xe
username: system
password:
verbose: true
referenceUrl: jdbc:oracle:thin:@localhost:1521/xe
referenceUsername: system
referencePassword:

dbchangelog . xml

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
    xmlns:pro="http://www.liquibase.org/xml/ns/pro" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

    <changeSet id="1" author="bob">
        <createTable tableName="department">
            <column name="id" type="int">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="active" type="boolean" defaultValueBoolean="true"/>
        </createTable>
    </changeSet>
        <changeSet id="2" author="bob">
        <createTable tableName="department2">
            <column name="id" type="int">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="active" type="boolean" defaultValueBoolean="true"/>
        </createTable>
    </changeSet>
</databaseChangeLog>

Команда выполнена

mvn liquibase:diff -Pprod

Выход Liquibase

$ mvn liquibase:diff -Pprod
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.jenkov:hello-world >-----------------------
[INFO] Building hello-world 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- liquibase-maven-plugin:3.8.7:diff (default-cli) @ hello-world ---
[INFO] ------------------------------------------------------------------------
[INFO] there are no resolved artifacts for the Maven project.
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase/liquibase-prod.properties
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO]
[INFO] Liquibase Community 3.8.7 by Datical
[INFO] Starting Liquibase at Fri, 20 Mar 2020 23:35:03 NZDT (version 3.8.7 #55 built at Mon Feb 24 03:04:51 UTC 2020)
[INFO] Parsing Liquibase Properties File src/main/resources/liquibase/liquibase-prod.properties for changeLog parameters
[INFO] Executing on Database: jdbc:oracle:thin:@localhost:1523/xe
[INFO] there are no resolved artifacts for the Maven project.
[INFO] there are no resolved artifacts for the Maven project.
[INFO] Performing Diff on database SYSTEM @ jdbc:oracle:thin:@localhost:1523/xe (Default Schema: SYSTEM)

Diff Results:
Reference Database: SYSTEM @ jdbc:oracle:thin:@localhost:1521/xe (Default Schema: SYSTEM)
Comparison Database: SYSTEM @ jdbc:oracle:thin:@localhost:1523/xe (Default Schema: SYSTEM)
Compared Schemas: SYSTEM
Product Name: EQUAL
Product Version: EQUAL
Missing Catalog(s): NONE
Unexpected Catalog(s): NONE
Changed Catalog(s): NONE
Missing Column(s): NONE
Unexpected Column(s): NONE
Changed Column(s): NONE
Missing Foreign Key(s): NONE
Unexpected Foreign Key(s): NONE
Changed Foreign Key(s): NONE
Missing Index(s): NONE
Unexpected Index(s): NONE
Changed Index(s): NONE
Missing Primary Key(s): NONE
Unexpected Primary Key(s): NONE
Changed Primary Key(s): NONE
Missing Sequence(s): NONE
Unexpected Sequence(s): NONE
Changed Sequence(s): NONE
Missing Table(s): NONE
Unexpected Table(s): NONE
Changed Table(s): NONE
Missing Unique Constraint(s): NONE
Unexpected Unique Constraint(s): NONE
Changed Unique Constraint(s): NONE
Missing View(s): NONE
Unexpected View(s): NONE
Changed View(s): NONE
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.087 s
[INFO] Finished at: 2020-03-20T23:35:03+13:00
[INFO] ------------------------------------------------------------------------
...