database - Liquibase 差异功能
问题描述
..所以我正在热身 Liquibase 并努力让liquibase diff功能正常工作。我希望我可以使用这个论坛来获得一些帮助。
问题描述
我用 changeset1 和 changeset2 更新了我的 Dev DB,而 Prod DB 只用 changeset1 更新了。使用 SQL 开发人员 UI,我可以看到在 Dev 和 Prod 上创建的 changeset1 对应的表,而 changeset2 对应的表不在 Prod DB 中。到目前为止,这是在预期的线路上。
但是,当我在 Prod 上执行liquibase diff并引用 Dev DB 时,我希望看到差异(changeset2)。但是,我没有看到 Liquibase 输出中列出的更改 - 因此这篇文章。我哪里会出错?
请注意,我使用的是 dockerised 的 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] ------------------------------------------------------------------------
解决方案
推荐阅读
- asp.net-mvc - 将表单数组数据一次保存到 AspnetCore MVC 中的数据库中
- vb.net - 当一个drawing.point在里面时Arraylist访问x和y
- javascript - 使用 Jest 获取 React 应用程序中的断言总数
- android - onGenericMotionEvent() 不起作用 - 为什么?
- c++ - 我的变量“n”自己递减,甚至没有提供递减操作。C++ - N_Queen_Problem 程序
- postgresql - 创建独特的字符变化数组 postgres
- jenkins - 如何获取 Jenkins 构建的开始和结束时间?
- postgresql - Rails Backup Gem 无法在从属设备上备份复制的 PostgreSQL 数据库,出现 pg_dump 权限错误
- python - python的kivy:弹出窗口和上一页之间的通信
- python - 如何通过将 setter 函数传递给 jitclass 本身来使用其字符串名称更新 jitclass 变量?