Liquibase 是管理业务中数据库结构版本的,用于跟踪、管理和应用数据库(表结构,数据等)变化,所以就会有这些概念:版本号,管理的数据,差异比较,版本回滚。目前Liquibase官方不支持GBase 8a数据库,但可以用mysql驱动。本文简单介绍liquibase并对GBase 8a集群9.5.3版本管理的样例。
目录导航
1. Introduction to Liquibase
- 支持多个作者
- 每个变动有编号ID, 与作者一起可看作唯一标识符。整个变动内容一旦更新则不可更改。
- 变动支持回退
- 变动文件可以多次改动,会自动更新变动的部分。
- 可以打tag,可用于整体回退
1.1. Standard Liquibase workflow
1.2. ChangeSets
Changesets contain Change Types, which are types of operations to apply to the database, such as adding a column or primary key. Context, label, and precondition changelog tags help precisely control when a database change is made and to which database environment it is deployed.
其中作者和ID是标识符,一旦update则不允许变动后面的内容。
SQL格式
-- changeset liquibaseuser:1
create table Details1 ( id int primary key, name varchar(255) );
-- rollback drop table Details1;
XML格式
<changeSet author="liquibase" id="30">
<createTable tableName="table30">
<column name="id" type="int"/>
<column name="heading" type="varchar(36)"/>
<column name="author" type="varchar(36)"/>
</createTable>
<rollback>
drop table table30
</rollback>
</changeSet>
1.3. ChangeLog
Liquibase uses SQL, XML, JSON, and YAML changelog files to list database changes in sequential order. Database changes have the format of changesets.
包含了按顺序列出的ChangeSets集合。
每个文件里的changeset要求作者和顺序号唯一,否则报重复
changesets had duplicate identifiers
changesets had duplicate identifiers
如果出现老的编号,且内容出现变动,报校验错误
nexpected error running Liquibase: Validation Failed:
1 changesets check sum
gbase.sql::1::XXX was: 9:70253bd57ffa0fa6faf0b0c0103ab76a but is now: 9:e602d9babfc3872b65daa05bd5c9c97e
<changeSet>
</changeSet>
<changeSet>
</changeSet>
<changeSet>
</changeSet>
...
1.4. Liquibase properties file
To set the connection between Liquibase with your database, you need the database connection information and parameters. Liquibase includes a properties file to store database connection information and parameters that rarely change. Setting the parameters as environment variables to handle sensitive database information or running them at the command prompt is an alternative option.
连接数据库的参数。
1.5. Liquibase commands
Liquibase runs six basic types of commands: update, rollback, snapshot, diff, status, and utility commands. When you use the update command to deploy your first changes, Liquibase checks the database connection information, including credentials, database URL, and JDBC driver.
命令,包括update,rollback,snapshot.diff,status和utility
1.5.1. Update
Commands used to execute undeployed changes specified in the changelog to a target database.
执行数据库未部署的改动
1.5.2. Rollback
Commands used to undo changes made to the database either automatically or with a custom rollback query.
回退。
1.5.3. Database Inspection
Commands used to compare differences between databases, or snapshots of databases over time.
包含了比较,快照等功能。
1.5.4. Utility
Commands used to manage changelogs, changesets, checksums, locks, and database schema documents.
管理工具
1.6. Database Changelog and Database Changelog Lock
When you deploy your changes, Liquibase creates two tables in your database: DATABASECHANGELOG and DATABASECHANGELOGLOCK.
The DATABASECHANGELOG table tracks deployed changes so that you have a record. Liquibase compares the changesets in the changelog file with the DATABASECHANGELOG tracking table and deploys only new changesets.
DATABASECHANGELOGLOCK prevents multiple instances of Liquibase from updating the database at the same time. The table manages access to the DATABASECHANGELOG table during deployment and ensures only one instance of Liquibase is updating the database.
自动建2张表
DATABASECHANGELOG 跟踪变动
DATABASECHANGELOGLOCK 避免并发
1.7. Executing Liquibase Commands
Liquibase commands can be executed through different types of interfaces for database change management. These include:
- Command-line interface (CLI)
- Liquibase flow files (Pro)
- Maven
- Spring Boot
- Java API
命令行最简单
Liquibase command parameters let users specify behavior when running Liquibase commands and are either global parameters or command parameters:
- Global parameters are used to change a global default behavior and can be used with any Liquibase command.
- Command parameters specify command-specific settings and values.
liquibase [global parameter] [command] [command parameter] liquibase [--changelog-file=dbchangelog.xml] [status] [--verbose]
Certain parameters are required to execute most commands. These include:
- --changelog-file: includes the path and filename of the changelog used.
- --url: the database JDBC URL value.
- --username*: the database username value.
- --password*: the password for the database.
2. Install Liquibase
To install Liquibase using the Red Hat/CentOS package manager, follow the steps below:
Import the Liquibase public key (as root):
rpm --import https://repo.liquibase.com/liquibase.asc
Install yum-config-manager:
yum install -y yum-utils
Add the remote repo to yum (as root):
yum-config-manager --add-repo https://repo.liquibase.com/repo-liquibase-com.repo
Install Liquibase:
yum install liquibase
安装过程
[root@gbase_rh7_003 ~]# rpm --import https://repo.liquibase.com/liquibase.asc
[root@gbase_rh7_003 ~]# yum install -y yum-utils
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies--> Running transaction check---> Package yum-utils.noarch 0:1.1.31-40.el7 will be updated---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be an update--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================
Package Arch Version Repository Size=========================================================================================================================================
Updating:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Transaction Summary=========================================================================================================================================
Upgrade 1 Package
Total download size: 122 k
Downloading packages:No Presto metadata available for base
yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00Running transaction checkRunning transaction test
Transaction test succeededRunning transaction
Updating : yum-utils-1.1.31-54.el7_8.noarch 1/2
Cleanup : yum-utils-1.1.31-40.el7.noarch 2/2
Verifying : yum-utils-1.1.31-54.el7_8.noarch 1/2
Verifying : yum-utils-1.1.31-40.el7.noarch 2/2
Updated:
yum-utils.noarch 0:1.1.31-54.el7_8
Complete!
[root@gbase_rh7_003 ~]# yum-config-manager --add-repo https://repo.liquibase.com/repo-liquibase-com.repo
Loaded plugins: langpacks, product-id
adding repo from: https://repo.liquibase.com/repo-liquibase-com.repo
grabbing file https://repo.liquibase.com/repo-liquibase-com.repo to /etc/yum.repos.d/repo-liquibase-com.repo
repo saved to /etc/yum.repos.d/repo-liquibase-com.repo
[root@gbase_rh7_003 ~]# yum install liquibase
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo.liquibase.com | 3.0 kB 00:00:00
repo.liquibase.com/primary_db | 37 kB 00:00:01
Resolving Dependencies--> Running transaction check---> Package liquibase.noarch 0:4.30.0-1 will be installed--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================
Package Arch Version Repository Size=========================================================================================================================================
Installing:
liquibase noarch 4.30.0-1 repo.liquibase.com 153 M
Transaction Summary=========================================================================================================================================
Install 1 Package
Total download size: 153 M
Installed size: 169 MIs this ok [y/d/N]: y
Downloading packages:
liquibase-4.30.0-1.noarch.rpm | 153 MB 00:10:13Running transaction checkRunning transaction test
Transaction test succeededRunning transaction
Installing : liquibase-4.30.0-1.noarch 1/1
Verifying : liquibase-4.30.0-1.noarch 1/1
Installed:
liquibase.noarch 0:4.30.0-1
Complete!
[root@gbase_rh7_003 ~]#
[root@gbase_rh7_003 liquibasegbase]# liquibase --version
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:26:27 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Home: /usr/bin
Java Home /usr/java/jdk1.8.0_291-amd64/jre (Version 1.8.0_291)
Libraries:
- internal/extensions/liquibase-commercial-bigquery.jar: Liquibase BigQuery Commercial Extension 4.30.0 By Liquibase
- internal/lib/commons-collections4.jar: Apache Commons Collections 4.4.0 By The Apache Software Foundation
- internal/lib/commons-io.jar: Apache Commons IO 2.17.0 By The Apache Software Foundation
- internal/lib/commons-lang3.jar: Apache Commons Lang 3.17.0 By The Apache Software Foundation
- internal/lib/commons-text.jar: Apache Commons Text 1.12.0 By The Apache Software Foundation
- internal/lib/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar: General Data Technology' JDBC Driver for GBase 8.3.81.53 By General Data Technology Inc.
- internal/lib/h2.jar: H2 Database Engine 2.2.224 By H2 Group
- internal/lib/hsqldb.jar: HSQLDB 2.7.3 By The HSQL Development Group
- internal/lib/jaxb-api.jar: jaxb-api 2.3.1 By Oracle Corporation
- internal/lib/jaxb-core.jar: JAXB Core 4.0.5 By Eclipse Foundation
- internal/lib/jaxb-runtime.jar: JAXB Runtime 4.0.5 By Eclipse Foundation
- internal/lib/jaybird.jar: Jaybird 5.0.5.java8 (build: variant=jaybird tag=v5.0.5 date=202406141523) By Firebird project
- internal/lib/jcc.jar: IBM JCC JDBC 4 Driver 1.4.0 By IBM
- internal/lib/liquibase-commercial.jar: Commercial Liquibase Functionality 4.30.0 By Liquibase
- internal/lib/mariadb-java-client.jar: mariadb-java-client 3.4.1 By mariadb.com
- internal/lib/mssql-jdbc.jar: Microsoft JDBC Driver for SQL Server 12.8.1 By Microsoft Corporation
- internal/lib/ojdbc8.jar: JDBC 19.24.0.0.0 By Oracle Corporation
- internal/lib/opencsv.jar: opencsv 5.9.0
- internal/lib/picocli.jar: picocli 4.7.6 By Remko Popma
- internal/lib/postgresql.jar: PostgreSQL JDBC Driver 42.7.4 By PostgreSQL Global Development Group
- internal/lib/slf4j-api.jar: SLF4J API Module 2.0.16 By SLF4J.ORG
- internal/lib/slf4j-simple.jar: SLF4J Simple Provider 2.0.16 By SLF4J.ORG
- internal/lib/snakeyaml.jar: SnakeYAML 2.3.0
- internal/lib/snowflake-jdbc.jar: snowflake-jdbc 3.18.0
- internal/lib/sqlite-jdbc.jar: SQLite JDBC 3.46.1.3
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
[root@gbase_rh7_003 liquibasegbase]#
3. Ensure Java is installed
[root@gbase_rh7_003 ~]# java -version
java version "1.8.0_291"Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)[root@gbase_rh7_003 ~]#
Jdbc jar包, 用mysql 5.0.7等老的版本,放到
/usr/bin/internal/lib
4. 生成项目
[root@gbase_rh7_003 gbase]# mkdir liquibasegbase
[root@gbase_rh7_003 gbase]# cd liquibasegbase/
[root@gbase_rh7_003 liquibasegbase]# liquibase init project-new
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Setup new liquibase.properties, flowfile, and sample changelog? Enter (Y)es with defaults, yes with (C)ustomization, or (N)o. [Y]:
yes
Setting up new Liquibase project in '/home/gbase/liquibasegbase/.'...
Created example changelog file '/home/gbase/liquibasegbase/example-changelog.sql'
Created example defaults file '/home/gbase/liquibasegbase/liquibase.properties'
Created example flow file '/home/gbase/liquibasegbase/liquibase.advanced.flowfile.yaml'
Created example flow file '/home/gbase/liquibasegbase/liquibase.flowvariables.yaml'
Created example flow file '/home/gbase/liquibasegbase/liquibase.endstage.flow'
Created example flow file '/home/gbase/liquibasegbase/liquibase.flowfile.yaml'
Created example checks package '/home/gbase/liquibasegbase/liquibase.checks-package.yaml'
To use the new project files make sure your database is active and accessible by opening a new terminal window to run "liquibase init start-h2", and then return to this terminal window to run "liquibase update" command.
For more details, visit the Getting Started Guide at https://docs.liquibase.com/start/home.html
Liquibase command 'init project' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]# ll
total 32
-rw-r--r-- 1 root root 832 Dec 7 10:18 example-changelog.sql
-rw-r--r-- 1 root root 4924 Dec 7 10:18 liquibase.advanced.flowfile.yaml
-rw-r--r-- 1 root root 1916 Dec 7 10:18 liquibase.checks-package.yaml
-rw-r--r-- 1 root root 985 Dec 7 10:18 liquibase.endstage.flow
-rw-r--r-- 1 root root 1160 Dec 7 10:18 liquibase.flowfile.yaml
-rw-r--r-- 1 root root 404 Dec 7 10:18 liquibase.flowvariables.yaml
-rw-r--r-- 1 root root 2752 Dec 7 10:18 liquibase.properties
[root@gbase_rh7_003 liquibasegbase]#
5. 编辑配置文件
编辑 liquibase.properties 将目标库的JDBC参数。 其中驱动用mysql,端口改成5258
#### Enter the Target database 'url' information ####liquibase.command.url=jdbc:mysql://10.0.2.103:5258/liquibase
# Enter the username for your Target database.liquibase.command.username: root
# Enter the password for your Target database.liquibase.command.password: XXXXXXX
6. 操作
6.1. Update
6.1.1. 增加自带的默认例子中的表
[root@gbase_rh7_003 liquibasegbase]# liquibase update
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Running Changeset: example-changelog.sql::1::your.name
Running Changeset: example-changelog.sql::2::your.name
Running Changeset: example-changelog.sql::3::other.dev
UPDATE SUMMARY
Run: 3
Previously run: 0
Filtered out: 0
-------------------------------
Total change sets: 3
Liquibase: Update has been successful. Rows affected: 3Liquibase command 'update' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]#
登录gbase查看结果
GBase client 9.5.3.28.18.r1_patch.3b726d68. Copyright (c) 2004-2024, GBase. All Rights Reserved.
gbase> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| performance_schema |
| gbase |
| gctmpdb |
| gclusterdb |
| liquibase |
| test1db |
| test_db |
| testdb |
+--------------------+
9 rows in set (Elapsed: 00:00:00.00)
gbase> use liquibase;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> show tables;
+-----------------------+
| Tables_in_liquibase |
+-----------------------+
| company |
| databasechangelog |
| databasechangeloglock |
| person |
+-----------------------+
4 rows in set (Elapsed: 00:00:00.00)
6.1.2. 新增一个GBase分布表
将配置文件里的默认sql改成gbase.sql,然后新增一个分布表。
[root@gbase_rh7_003 liquibasegbase]# vi gbase.sql
[root@gbase_rh7_003 liquibasegbase]# cat gbase.sql
--liquibase formatted sql
--changeset XXX:1 labels:建分布表 context:建数字int类型的分布表
--comment: example comment
create table gbase (
id int,
name varchar(50)
)distributed by('id')
--rollback DROP TABLE gbase;
[root@gbase_rh7_003 liquibasegbase]# liquibase update
Running Changeset: gbase.sql::1::XXX
UPDATE SUMMARY
Run: 1
Previously run: 0
Filtered out: 0
-------------------------------
Total change sets: 1
Liquibase: Update has been successful. Rows affected: 1
Liquibase command 'update' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]#
查看分布表效果
gbase> show tables;
+-----------------------+
| Tables_in_liquibase |
+-----------------------+
| company |
| databasechangelog |
| databasechangeloglock |
| gbase |
| person |
+-----------------------+
5 rows in set (Elapsed: 00:00:00.00)
6.1.3. 一次多个变动例子
标签相同的,不会更新,只有新增的才会变动。适合同一个变动文件,做了多次变动的情况。
[root@gbase_rh7_003 liquibasegbase]# cat gbase.sql--liquibase formatted sql
--changeset XXX:2 labels:建分布表2 context:建数字int类型的分布表2--comment: 分布表2create table gbase2 (
id int,
name varchar(50)
)distributed by('id')--rollback DROP TABLE gbase2;
--changeset XXX:3 labels:建复制表1 context:建复制表1--comment: 复制表1create table gbaserep (
id int,
name varchar(50)
)replicated--rollback DROP TABLE gbaserep;
[root@gbase_rh7_003 liquibasegbase]#
6.2. Tag
给当前的版本一个标签。从数据库的表里能查到。
[root@gbase_rh7_003 liquibasegbase]# liquibase tag 'test000'
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Successfully tagged 'root@10.0.2.103@jdbc:mysql://10.0.2.103:5258/liquibase'
Liquibase command 'tag' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]#
gbase> select * from databasechangelog;
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
| ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | MD5SUM | DESCRIPTION | COMMENTS | TAG | LIQUIBASE | CONTEXTS | LABELS | DEPLOYMENT_ID |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
| 1 | your.name | example-changelog.sql | 2024-12-07 10:55:57 | 1 | EXECUTED | 9:f6d6b04fbf860e734bbcaa93c2207423 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 2 | your.name | example-changelog.sql | 2024-12-07 10:55:58 | 2 | EXECUTED | 9:8105cd2916fe5e4a0d7e030fd54037dc | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 3 | other.dev | example-changelog.sql | 2024-12-07 10:55:58 | 3 | EXECUTED | 9:7ce8f8f671c85fee99df053c02c385f2 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 1 | XXX | gbase.sql | 2024-12-07 11:08:48 | 4 | EXECUTED | 9:70253bd57ffa0fa6faf0b0c0103ab76a | sql | example comment | test000 | 4.30.0 | 建数字int类型的分布表 | 建分布表 | 3540927873 |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
4 rows in set (Elapsed: 00:00:00.00)
6.3. Rollback
回退到指定的标签。 再update一次,建gbase2的表。 打上新的标签,然后回退到上一个。
[root@gbase_rh7_003 liquibasegbase]# cat gbase.sql
--liquibase formatted sql
--changeset XXX:2 labels:建分布表2 context:建数字int类型的分布表2
--comment: example comment
create table gbase2 (
id int,
name varchar(50)
)distributed by('id')
--rollback DROP TABLE gbase2;
[root@gbase_rh7_003 liquibasegbase]#
[root@gbase_rh7_003 liquibasegbase]# liquibase update
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Running Changeset: gbase.sql::2::XXX
UPDATE SUMMARY
Run: 1
Previously run: 0
Filtered out: 0
-------------------------------
Total change sets: 1
Liquibase: Update has been successful. Rows affected: 1
Liquibase command 'update' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]# liquibase tag 'test001'
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Successfully tagged 'root@10.0.2.103@jdbc:mysql://10.0.2.103:5258/liquibase'
Liquibase command 'tag' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]#
gbase> show tables;
+-----------------------+
| Tables_in_liquibase |
+-----------------------+
| company |
| databasechangelog |
| databasechangeloglock |
| gbase |
| gbase2 |
| person |
+-----------------------+
6 rows in set (Elapsed: 00:00:00.00)
gbase> select * from databasechangelog;
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+---------------------------------+---------------+---------------+
| ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | MD5SUM | DESCRIPTION | COMMENTS | TAG | LIQUIBASE | CONTEXTS | LABELS | DEPLOYMENT_ID |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+---------------------------------+---------------+---------------+
| 1 | your.name | example-changelog.sql | 2024-12-07 10:55:57 | 1 | EXECUTED | 9:f6d6b04fbf860e734bbcaa93c2207423 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 2 | your.name | example-changelog.sql | 2024-12-07 10:55:58 | 2 | EXECUTED | 9:8105cd2916fe5e4a0d7e030fd54037dc | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 3 | other.dev | example-changelog.sql | 2024-12-07 10:55:58 | 3 | EXECUTED | 9:7ce8f8f671c85fee99df053c02c385f2 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 1 | XXX | gbase.sql | 2024-12-07 11:08:48 | 4 | EXECUTED | 9:70253bd57ffa0fa6faf0b0c0103ab76a | sql | example comment | test000 | 4.30.0 | 建数字int类型的分布表 | 建分布表 | 3540927873 |
| 2 | XXX | gbase.sql | 2024-12-07 11:30:21 | 5 | EXECUTED | 9:e602d9babfc3872b65daa05bd5c9c97e | sql | example comment | test001 | 4.30.0 | 建数字int类型的分布表2 | 建分布表2 | 3542221297 |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+---------------------------------+---------------+---------------+
5 rows in set (Elapsed: 00:00:00.01)
[root@gbase_rh7_003 liquibasegbase]# liquibase rollback 'test000'
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at docs.liquibase.com ##
## Get certified courses at learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 10:55:55 using Java 1.8.0_291 (version 4.30.0 #4943 built at 2024-10-31 17:00+0000)
Liquibase Version: 4.30.0
Liquibase Open Source 4.30.0 by Liquibase
Rolling Back Changeset: gbase.sql::2::XXX
Liquibase command 'rollback' was executed successfully.
[root@gbase_rh7_003 liquibasegbase]#
gbase> show tables;
+-----------------------+
| Tables_in_liquibase |
+-----------------------+
| company |
| databasechangelog |
| databasechangeloglock |
| gbase |
| person |
+-----------------------+
5 rows in set (Elapsed: 00:00:00.00)
gbase> select * from databasechangelog;
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
| ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | MD5SUM | DESCRIPTION | COMMENTS | TAG | LIQUIBASE | CONTEXTS | LABELS | DEPLOYMENT_ID |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
| 1 | your.name | example-changelog.sql | 2024-12-07 10:55:57 | 1 | EXECUTED | 9:f6d6b04fbf860e734bbcaa93c2207423 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 2 | your.name | example-changelog.sql | 2024-12-07 10:55:58 | 2 | EXECUTED | 9:8105cd2916fe5e4a0d7e030fd54037dc | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 3 | other.dev | example-changelog.sql | 2024-12-07 10:55:58 | 3 | EXECUTED | 9:7ce8f8f671c85fee99df053c02c385f2 | sql | example comment | NULL | 4.30.0 | example-context | example-label | 3540157531 |
| 1 | XXX | gbase.sql | 2024-12-07 11:08:48 | 4 | EXECUTED | 9:70253bd57ffa0fa6faf0b0c0103ab76a | sql | example comment | test000 | 4.30.0 | 建数字int类型的分布表 | 建分布表 | 3540927873 |
+----+-----------+-----------------------+---------------------+---------------+----------+------------------------------------+-------------+-----------------+---------+-----------+--------------------------------+---------------+---------------+
4 rows in set (Elapsed: 00:00:00.01)
7. 命令行参数
[root@gbase_rh7_003 liquibasegbase]# liquibase --help
Usage: liquibase [GLOBAL OPTIONS] [COMMAND] [COMMAND OPTIONS]
Command-specific help: "liquibase <command-name> --help"
Global Options
--allow-duplicated-changeset-identifiers=PARAM
Allows duplicated changeset identifiers without failing Liquibase execution.
DEFAULT: false
(defaults file: 'liquibase.allowDuplicatedChangesetIdentifiers', environment variable:
'LIQUIBASE_ALLOW_DUPLICATED_CHANGESET_IDENTIFIERS')
--always-drop-instead-of-replace=PARAM
If true, drop and recreate a view instead of replacing it.
DEFAULT: false
(defaults file: 'liquibase.alwaysDropInsteadOfReplace', environment variable: 'LIQUIBASE_ALWAYS_DROP_INSTEAD_OF_REPLACE')
--always-override-stored-logic-schema=PARAM
When generating SQL for createProcedure, should the procedure schema be forced to the default schema if no schemaName attribute is set?
DEFAULT: false
(defaults file: 'liquibase.alwaysOverrideStoredLogicSchema', environment variable: 'LIQUIBASE_ALWAYS_OVERRIDE_STORED_LOGIC_SCHEMA')
--analytics-enabled=PARAM
Enable or disable sending product usage data and analytics to Liquibase. Learn more at https://docs.liquibase.com/analytics. DEFAULT:
true for OSS users | false for PRO users
(defaults file: 'liquibase.analytics.enabled', environment variable: 'LIQUIBASE_ANALYTICS_ENABLED')
--auto-reorg=PARAM Should Liquibase automatically include REORG TABLE commands when needed?
DEFAULT: true
(defaults file: 'liquibase.autoReorg', environment variable: 'LIQUIBASE_AUTO_REORG')
--changelog-lock-poll-rate=PARAM
Number of seconds wait between checks to the changelog lock when it is locked
DEFAULT: 10
(defaults file: 'liquibase.changelogLockPollRate', environment variable: 'LIQUIBASE_CHANGELOG_LOCK_POLL_RATE')
--changelog-lock-wait-time-in-minutes=PARAM
Number of minutes to wait for the changelog lock to be available before giving up
DEFAULT: 5
(defaults file: 'liquibase.changelogLockWaitTimeInMinutes', environment variable: 'LIQUIBASE_CHANGELOG_LOCK_WAIT_TIME_IN_MINUTES')
--changelog-parse-mode=PARAM
Configures how to handle unknown fields in changelog files. Possible values: STRICT which causes parsing to fail, and LAX which
continues with the parsing.
DEFAULT: STRICT
(defaults file: 'liquibase.changelogParseMode', environment variable: 'LIQUIBASE_CHANGELOG_PARSE_MODE')
--classpath=PARAM Additional classpath entries to use
(defaults file: 'liquibase.classpath', environment variable: 'LIQUIBASE_CLASSPATH')
--convert-data-types=PARAM
Should Liquibase convert to/from STANDARD data types. Applies to both snapshot and update commands.
DEFAULT: true
(defaults file: 'liquibase.convertDataTypes', environment variable: 'LIQUIBASE_CONVERT_DATA_TYPES')
--custom-log-data-file=PARAM
[PRO]
Relative or fully qualified path to a yaml file containing key:value data to inject or exclude data from JSON structured logs. Learn
more at https://docs.liquibase.com/structured-logging
(defaults file: 'liquibase.customLogDataFile', environment variable: 'LIQUIBASE_CUSTOM_LOG_DATA_FILE')
--custom-log-data-frequency=PARAM
[PRO]
The frequency that the custom log data will be entered into the logs. Available options are: ONCE,REPEATED
DEFAULT: REPEATED
(defaults file: 'liquibase.customLogDataFrequency', environment variable: 'LIQUIBASE_CUSTOM_LOG_DATA_FREQUENCY')
--database-changelog-lock-table-name=PARAM
Name of table to use for tracking concurrent Liquibase usage
DEFAULT: DATABASECHANGELOGLOCK
(defaults file: 'liquibase.databaseChangelogLockTableName', environment variable: 'LIQUIBASE_DATABASE_CHANGELOG_LOCK_TABLE_NAME')
--database-changelog-table-name=PARAM
Name of table to use for tracking change history
DEFAULT: DATABASECHANGELOG
(defaults file: 'liquibase.databaseChangelogTableName', environment variable: 'LIQUIBASE_DATABASE_CHANGELOG_TABLE_NAME')
--database-class=PARAM Class to use for Database implementation
(defaults file: 'liquibase.databaseClass', environment variable: 'LIQUIBASE_DATABASE_CLASS')
--dbclhistory-capture-extensions=PARAM
If true, extensions are captured in the history table
DEFAULT: true
(defaults file: 'liquibase.dbclhistory.captureExtensions', environment variable: 'LIQUIBASE_DBCLHISTORY_CAPTURE_EXTENSIONS')
--dbclhistory-capture-sql=PARAM
If true, executed SQL is captured in the history table
DEFAULT: true
(defaults file: 'liquibase.dbclhistory.captureSql', environment variable: 'LIQUIBASE_DBCLHISTORY_CAPTURE_SQL')
--dbclhistory-enabled=PARAM
[PRO]
This property enables Liquibase Pro users to store a record of all database changing liquibase operations in a new table
DATABASECHANGELOGHISTORY. This table includes records of rollback, dropalls, and repeated runOnChange type activity, which is not
available in the standard DATABASECHANGELOG table.
DEFAULT: false
(defaults file: 'liquibase.dbclhistory.enabled', environment variable: 'LIQUIBASE_DBCLHISTORY_ENABLED')
--dbclhistory-severity=PARAM
The exit code to use if an exception is encountered while recording history events
DEFAULT: 1
(defaults file: 'liquibase.dbclhistory.severity', environment variable: 'LIQUIBASE_DBCLHISTORY_SEVERITY')
--ddl-lock-timeout=PARAM
The DDL_LOCK_TIMEOUT parameter indicates the number of seconds a DDL command should wait for the locks to become available before
throwing the resource busy error message. This applies only to Oracle databases.
(defaults file: 'liquibase.ddlLockTimeout', environment variable: 'LIQUIBASE_DDL_LOCK_TIMEOUT')
--defaults-file=PARAM File with default Liquibase properties
DEFAULT: liquibase.properties
(defaults file: 'liquibase.defaultsFile', environment variable: 'LIQUIBASE_DEFAULTS_FILE')
--diff-column-order=PARAM
Should Liquibase compare column order in diff operation?
DEFAULT: true
(defaults file: 'liquibase.diffColumnOrder', environment variable: 'LIQUIBASE_DIFF_COLUMN_ORDER')
--driver=PARAM Database driver class
(defaults file: 'liquibase.driver', environment variable: 'LIQUIBASE_DRIVER')
--driver-properties-file=PARAM
Driver-specific properties
(defaults file: 'liquibase.driverPropertiesFile', environment variable: 'LIQUIBASE_DRIVER_PROPERTIES_FILE')
--duplicate-file-mode=PARAM
How to handle multiple files being found in the search path that have duplicate paths. Options are SILENT (do not log and choose one at
random), DEBUG, INFO, WARN (log at the given level and choose one at random), or ERROR (fail current operation).
DEFAULT: ERROR
(defaults file: 'liquibase.duplicateFileMode', environment variable: 'LIQUIBASE_DUPLICATE_FILE_MODE')
--error-on-circular-include-all=PARAM
Throw an error if Liquibase detects that an includeAll will cause a circular reference (and thus a changelog parse error).
DEFAULT: true
(defaults file: 'liquibase.errorOnCircularIncludeAll', environment variable: 'LIQUIBASE_ERROR_ON_CIRCULAR_INCLUDE_ALL')
--file-encoding=PARAM Encoding to use when reading files. Valid values include: UTF-8, UTF-16, UTF-16BE, UTF-16LE, US-ASCII, or OS to use the system
configured encoding.
DEFAULT: UTF-8
(defaults file: 'liquibase.fileEncoding', environment variable: 'LIQUIBASE_FILE_ENCODING')
--filter-log-messages=PARAM
DEPRECATED: No longer used
(defaults file: 'liquibase.filterLogMessages', environment variable: 'LIQUIBASE_FILTER_LOG_MESSAGES')
--generate-changeset-created-values=PARAM
Should Liquibase include a 'created' attribute in diff/generateChangelog changesets with the current datetime
DEFAULT: false
(defaults file: 'liquibase.generateChangesetCreatedValues', environment variable: 'LIQUIBASE_GENERATE_CHANGESET_CREATED_VALUES')
--generated-changeset-ids-contains-description=PARAM
Should Liquibase include the change description in the id when generating changesets?
DEFAULT: false
(defaults file: 'liquibase.generatedChangesetIdsContainsDescription', environment variable:
'LIQUIBASE_GENERATED_CHANGESET_IDS_CONTAINS_DESCRIPTION')
-h, --help Show this help message and exit
--headless=PARAM Force Liquibase to think it has no access to a keyboard
DEFAULT: false
(defaults file: 'liquibase.headless', environment variable: 'LIQUIBASE_HEADLESS')
--include-catalog-in-specification=PARAM
Should Liquibase include the catalog name when determining equality?
DEFAULT: false
(defaults file: 'liquibase.includeCatalogInSpecification', environment variable: 'LIQUIBASE_INCLUDE_CATALOG_IN_SPECIFICATION')
--include-relations-for-computed-columns=PARAM
If true, the parent relationship for computed columns is preserved in snapshot-dependent commands: snapshot and diff
DEFAULT: false
(defaults file: 'liquibase.includeRelationsForComputedColumns', environment variable:
'LIQUIBASE_INCLUDE_RELATIONS_FOR_COMPUTED_COLUMNS')
--include-system-classpath=PARAM
Include the system classpath when resolving classes at runtime
DEFAULT: true
(defaults file: 'liquibase.includeSystemClasspath', environment variable: 'LIQUIBASE_INCLUDE_SYSTEM_CLASSPATH')
--license-key=PARAM Liquibase Pro or Liquibase Labs license key used to unlock paid capabilities. Get a free trial at
https://liquibase.com/trial and use in CLI or add liquibase.licenseKey=<yourKey> into your defaults file.
(defaults file: 'liquibase.licenseKey', environment variable: 'LIQUIBASE_LICENSE_KEY')
--liquibase-catalog-name=PARAM
Catalog to use for Liquibase objects
(defaults file: 'liquibase.liquibaseCatalogName', environment variable: 'LIQUIBASE_LIQUIBASE_CATALOG_NAME')
--liquibase-schema-name=PARAM
Schema to use for Liquibase objects
(defaults file: 'liquibase.liquibaseSchemaName', environment variable: 'LIQUIBASE_LIQUIBASE_SCHEMA_NAME')
--liquibase-tablespace-name=PARAM
Tablespace to use for Liquibase objects
(defaults file: 'liquibase.liquibaseTablespaceName', environment variable: 'LIQUIBASE_LIQUIBASE_TABLESPACE_NAME')
--log-channels=PARAM DEFAULT: Controls which log channels have their level set by the liquibase.logLevel setting. Comma separate multiple values. To set the
level of all channels, use 'all'. Example: liquibase,org.mariadb.jdbc
(defaults file: 'liquibase.logChannels', environment variable: 'LIQUIBASE_LOG_CHANNELS')
--log-file=PARAM (defaults file: 'liquibase.logFile', environment variable: 'LIQUIBASE_LOG_FILE')
--log-format=PARAM Sets the format of log output to console or log files. Open Source users default to unstructured "TEXT" logs to the console or output
log files. Pro users have the option to set value as "JSON" or "JSON_PRETTY" to enable json-structured log files to the console or
output log files.
DEFAULT: TEXT
(defaults file: 'liquibase.logFormat', environment variable: 'LIQUIBASE_LOG_FORMAT')
--log-level=PARAM DEFAULT: Controls which logs get set to stderr AND to any log file. The CLI defaults, if log file set, to SEVERE. Others vary by
integration. The official log levels are: OFF, SEVERE, WARNING, INFO, FINE
(defaults file: 'liquibase.logLevel', environment variable: 'LIQUIBASE_LOG_LEVEL')
--mirror-console-messages-to-log=PARAM
When set to true, the console messages are mirrored to the logs as [liquibase.ui] to provide a more complete picture of liquibase
operations to log analysis tools. Set to false to change this behavior.
DEFAULT: true
(defaults file: 'liquibase.mirrorConsoleMessagesToLog', environment variable: 'LIQUIBASE_MIRROR_CONSOLE_MESSAGES_TO_LOG')
--mirror-output-to-console=PARAM
[PRO]
When set to true, console output will be mirrored to both the specified output-file and the console. If output-file is not set, the
'mirror-output-to-console' argument has no effect.
DEFAULT: false
(defaults file: 'liquibase.mirrorOutputToConsole', environment variable: 'LIQUIBASE_MIRROR_OUTPUT_TO_CONSOLE')
--missing-property-mode=PARAM
How to handle changelog property expressions where a value is not set. For example, a string 'null' when no 'address' property was
defined. Values can be: 'preserve' which leaves the string as-is, 'empty' which replaces it with an empty string, or 'error' which
stops processing with an error.
DEFAULT: PRESERVE
(defaults file: 'liquibase.missingPropertyMode', environment variable: 'LIQUIBASE_MISSING_PROPERTY_MODE')
--monitor-performance=PARAM
Enable performance tracking. Set to 'false' to disable. If set to 'true', data is stored to a `liquibase-TIMESTAMP.jfr` file in your
working directory. Any other value will enable tracking and be used as the name of the file to write the data to.
DEFAULT: false
(defaults file: 'liquibase.monitorPerformance', environment variable: 'LIQUIBASE_MONITOR_PERFORMANCE')
--on-missing-include-changelog=PARAM
If set to WARN, then liquibase will not throw exception on missing changelog file, instead will show a warning message.
DEFAULT: FAIL
(defaults file: 'liquibase.onMissingIncludeChangelog', environment variable: 'LIQUIBASE_ON_MISSING_INCLUDE_CHANGELOG')
--output-file=PARAM (defaults file: 'liquibase.outputFile', environment variable: 'LIQUIBASE_OUTPUT_FILE')
--output-file-encoding=PARAM
Encoding to use when writing files
DEFAULT: UTF-8
(defaults file: 'liquibase.outputFileEncoding', environment variable: 'LIQUIBASE_OUTPUT_FILE_ENCODING')
--output-line-separator=PARAM
Line separator for output
DEFAULT: Line separator(LF or CRLF) for output. Defaults to OS default
(defaults file: 'liquibase.outputLineSeparator', environment variable: 'LIQUIBASE_OUTPUT_LINE_SEPARATOR')
--preserve-classpath-prefix-in-normalized-paths=PARAM
If true 'classpath:' prefix will be preserved in normalized paths, allowing to resolve hierarchical resources under a classpath-based
root.
DEFAULT: false
(defaults file: 'liquibase.preserveClasspathPrefixInNormalizedPaths', environment variable:
'LIQUIBASE_PRESERVE_CLASSPATH_PREFIX_IN_NORMALIZED_PATHS')
--preserve-schema-case=PARAM
If true, Liquibase treats schema and catalog names as case sensitive
DEFAULT: false
(defaults file: 'liquibase.preserveSchemaCase', environment variable: 'LIQUIBASE_PRESERVE_SCHEMA_CASE')
--pro-global-end-delimiter=PARAM
[PRO]
The default end delimiter to use for all change sets
(defaults file: 'liquibase.pro.globalEndDelimiter', environment variable: 'LIQUIBASE_PRO_GLOBAL_END_DELIMITER')
--pro-global-end-delimiter-prioritized=PARAM
[PRO]
If true, the global end delimiter overrides all other settings
DEFAULT: false
(defaults file: 'liquibase.pro.globalEndDelimiter.prioritized', environment variable: 'LIQUIBASE_PRO_GLOBAL_END_DELIMITER_PRIORITIZED')
--pro-global-strip-comments=PARAM
[PRO]
The default strip comments to use for all change sets
(defaults file: 'liquibase.pro.globalStripComments', environment variable: 'LIQUIBASE_PRO_GLOBAL_STRIP_COMMENTS')
--pro-global-strip-comments-prioritized=PARAM
[PRO]
If true, the global strip comments overrides all other settings
DEFAULT: false
(defaults file: 'liquibase.pro.globalStripComments.prioritized', environment variable:
'LIQUIBASE_PRO_GLOBAL_STRIP_COMMENTS_PRIORITIZED')
--pro-license-key=PARAM
DEPRECATED: Liquibase Pro license key used to unlock paid capabilities. Get a free trial at
https://www.liquibase.com/protrial and use in CLI or add liquibase.pro.licenseKey=<yourKey> into your defaults file.
(defaults file: 'liquibase.pro.licenseKey', environment variable: 'LIQUIBASE_PRO_LICENSE_KEY')
--pro-mark-unused-not-drop=PARAM
If a column would be dropped in a diffChangeLog, call markUnused instead if set to true
DEFAULT: false
(defaults file: 'liquibase.pro.markUnusedNotDrop', environment variable: 'LIQUIBASE_PRO_MARK_UNUSED_NOT_DROP')
--pro-sql-inline=PARAM If true, generate changeSets with SQL-based changes inlined instead of saving them to an external file
DEFAULT: false
(defaults file: 'liquibase.pro.sql.inline', environment variable: 'LIQUIBASE_PRO_SQL_INLINE')
--pro-strict=PARAM [PRO]
If true, the Liquibase operations will fail when specified paths to Pro resource files (flow files, checks settings files, native
executor conf files, etc) or rollback scripts are missing or empty.
DEFAULT: false
(defaults file: 'liquibase.proStrict', environment variable: 'LIQUIBASE_PRO_STRICT')
--pro-synonyms-drop-public=PARAM
If false, do not drop public synonyms in diffChangeLog/dropAll
DEFAULT: true
(defaults file: 'liquibase.pro.synonyms.drop.public', environment variable: 'LIQUIBASE_PRO_SYNONYMS_DROP_PUBLIC')
--prompt-for-non-local-database=PARAM
Should Liquibase prompt if a non-local database is being accessed
(defaults file: 'liquibase.promptForNonLocalDatabase', environment variable: 'LIQUIBASE_PROMPT_FOR_NON_LOCAL_DATABASE')
--property-provider-class=PARAM
Implementation of Properties class to provide additional driver properties
(defaults file: 'liquibase.propertyProviderClass', environment variable: 'LIQUIBASE_PROPERTY_PROVIDER_CLASS')
--psql-args=PARAM Extra arguments which will be passed to the psql executable
(defaults file: 'liquibase.psql.args', environment variable: 'LIQUIBASE_PSQL_ARGS')
--psql-keep-temp=PARAM Retain generated sql files
(defaults file: 'liquibase.psql.keep.temp', environment variable: 'LIQUIBASE_PSQL_KEEP_TEMP')
--psql-keep-temp-name=PARAM
Optionally, specify a custom filename
(defaults file: 'liquibase.psql.keep.temp.name', environment variable: 'LIQUIBASE_PSQL_KEEP_TEMP_NAME')
--psql-keep-temp-path=PARAM
Optionally, specify the path in which to store the temporary files. If not specified, the files will be stored in the system's temp
directory
(defaults file: 'liquibase.psql.keep.temp.path', environment variable: 'LIQUIBASE_PSQL_KEEP_TEMP_PATH')
--psql-log-file=PARAM Log file for psql output
(defaults file: 'liquibase.psql.logFile', environment variable: 'LIQUIBASE_PSQL_LOG_FILE')
--psql-path=PARAM Path to psql executable
(defaults file: 'liquibase.psql.path', environment variable: 'LIQUIBASE_PSQL_PATH')
--psql-timeout=PARAM Seconds to wait for psql timeout
(defaults file: 'liquibase.psql.timeout', environment variable: 'LIQUIBASE_PSQL_TIMEOUT')
--reports-enabled=PARAM
[PRO]
Enable or disable reporting.
DEFAULT: true
(defaults file: 'liquibase.reports.enabled', environment variable: 'LIQUIBASE_REPORTS_ENABLED')
--reports-name=PARAM [PRO]
The name of the reports.
DEFAULT: report-dd-MMM-yyyy-HHmmss
(defaults file: 'liquibase.reports.name', environment variable: 'LIQUIBASE_REPORTS_NAME')
--reports-open=PARAM [PRO]
Open the newly generated report in your default browser.
DEFAULT: true
(defaults file: 'liquibase.reports.open', environment variable: 'LIQUIBASE_REPORTS_OPEN')
--reports-path=PARAM [PRO]
The path to the directory to generate the reports.
DEFAULT: .
(defaults file: 'liquibase.reports.path', environment variable: 'LIQUIBASE_REPORTS_PATH')
--search-path=PARAM Complete list of Location(s) to search for files such as changelog files in. Multiple paths can be specified by separating them with
commas.
(defaults file: 'liquibase.searchPath', environment variable: 'LIQUIBASE_SEARCH_PATH')
--secure-parsing=PARAM If true, remove functionality from file parsers which could be used insecurely. Examples include (but not limited to) disabling remote
XML entity support.
DEFAULT: true
(defaults file: 'liquibase.secureParsing', environment variable: 'LIQUIBASE_SECURE_PARSING')
--should-run=PARAM Should Liquibase commands execute
DEFAULT: true
(defaults file: 'liquibase.shouldRun', environment variable: 'LIQUIBASE_SHOULD_RUN')
--should-snapshot-data=PARAM
Should Liquibase snapshot data by default?
DEFAULT: false
(defaults file: 'liquibase.shouldSnapshotData', environment variable: 'LIQUIBASE_SHOULD_SNAPSHOT_DATA')
--show-banner=PARAM If true, show a Liquibase banner on startup.
DEFAULT: true
(defaults file: 'liquibase.showBanner', environment variable: 'LIQUIBASE_SHOW_BANNER')
--sql-log-level=PARAM Level to log SQL statements to
DEFAULT: FINE
(defaults file: 'liquibase.sql.logLevel', environment variable: 'LIQUIBASE_SQL_LOG_LEVEL')
--sql-show-sql-warnings=PARAM
Show SQLWarning messages
DEFAULT: true
(defaults file: 'liquibase.sql.showSqlWarnings', environment variable: 'LIQUIBASE_SQL_SHOW_SQL_WARNINGS')
--sqlcmd-args=PARAM Extra arguments which will be passed to the sqlcmd executable
(defaults file: 'liquibase.sqlcmd.args', environment variable: 'LIQUIBASE_SQLCMD_ARGS')
--sqlcmd-catalog-name=PARAM
Database to use when running SQLCMD
(defaults file: 'liquibase.sqlcmd.catalogName', environment variable: 'LIQUIBASE_SQLCMD_CATALOG_NAME')
--sqlcmd-keep-temp=PARAM
If true, do not delete temporary sql files generated
(defaults file: 'liquibase.sqlcmd.keep.temp', environment variable: 'LIQUIBASE_SQLCMD_KEEP_TEMP')
--sqlcmd-keep-temp-name=PARAM
Optionally, specify a custom filename
(defaults file: 'liquibase.sqlcmd.keep.temp.name', environment variable: 'LIQUIBASE_SQLCMD_KEEP_TEMP_NAME')
--sqlcmd-keep-temp-overwrite=PARAM
If true, overwrite any files in the specified directory with the same name
(defaults file: 'liquibase.sqlcmd.keep.temp.overwrite', environment variable: 'LIQUIBASE_SQLCMD_KEEP_TEMP_OVERWRITE')
--sqlcmd-keep-temp-path=PARAM
Optionally, specify the path in which to store the temporary files. If not specified, the files will be stored in the system's temp
directory.
(defaults file: 'liquibase.sqlcmd.keep.temp.path', environment variable: 'LIQUIBASE_SQLCMD_KEEP_TEMP_PATH')
--sqlcmd-log-file=PARAM
Log file for SQLCMD output
(defaults file: 'liquibase.sqlcmd.logFile', environment variable: 'LIQUIBASE_SQLCMD_LOG_FILE')
--sqlcmd-path=PARAM Path to sqlcmd executable
(defaults file: 'liquibase.sqlcmd.path', environment variable: 'LIQUIBASE_SQLCMD_PATH')
--sqlcmd-timeout=PARAM Seconds to wait for sqlcmd timeout
(defaults file: 'liquibase.sqlcmd.timeout', environment variable: 'LIQUIBASE_SQLCMD_TIMEOUT')
--sqlplus-args=PARAM Extra arguments which will be passed to the sqlplus executable
(defaults file: 'liquibase.sqlplus.args', environment variable: 'LIQUIBASE_SQLPLUS_ARGS')
--sqlplus-create-spool=PARAM
If true, create an Oracle spool file
(defaults file: 'liquibase.sqlplus.createSpool', environment variable: 'LIQUIBASE_SQLPLUS_CREATE_SPOOL')
--sqlplus-keep-temp-name=PARAM
Optionally, specify a custom filename
(defaults file: 'liquibase.sqlplus.keep.temp.name', environment variable: 'LIQUIBASE_SQLPLUS_KEEP_TEMP_NAME')
--sqlplus-keep-temp-overwrite=PARAM
If true, overwrite any files in the specified directory with the same name
(defaults file: 'liquibase.sqlplus.keep.temp.overwrite', environment variable: 'LIQUIBASE_SQLPLUS_KEEP_TEMP_OVERWRITE')
--sqlplus-keep-temp-path=PARAM
Optionally, specify the path in which to store the temporary files. If not specified, the files will be stored in the system's temp
directory.
(defaults file: 'liquibase.sqlplus.keep.temp.path', environment variable: 'LIQUIBASE_SQLPLUS_KEEP_TEMP_PATH')
--sqlplus-password=PARAM
Optionally, specify the pasword to use when executing. If not specified, the regular password will be used.
(defaults file: 'liquibase.sqlplus.password', environment variable: 'LIQUIBASE_SQLPLUS_PASSWORD')
--sqlplus-path=PARAM Path to sqlplus executable
(defaults file: 'liquibase.sqlplus.path', environment variable: 'LIQUIBASE_SQLPLUS_PATH')
--sqlplus-sqlerror=PARAM
Value to be used for the WHENEVER clause when sqlplus executes
(defaults file: 'liquibase.sqlplus.sqlerror', environment variable: 'LIQUIBASE_SQLPLUS_SQLERROR')
--sqlplus-timeout=PARAM
Seconds to wait for sqlplus timeout
(defaults file: 'liquibase.sqlplus.timeout', environment variable: 'LIQUIBASE_SQLPLUS_TIMEOUT')
--sqlplus-username=PARAM
Optionally, specify the username to use when executing. If not specified, the regular username will be used.
(defaults file: 'liquibase.sqlplus.username', environment variable: 'LIQUIBASE_SQLPLUS_USERNAME')
--strict=PARAM If true, Liquibase enforces certain best practices and proactively looks for common errors
DEFAULT: false
(defaults file: 'liquibase.strict', environment variable: 'LIQUIBASE_STRICT')
--support-property-escaping=PARAM
Support escaping changelog parameters using a colon. Example: null
DEFAULT: false
(defaults file: 'liquibase.supportPropertyEscaping', environment variable: 'LIQUIBASE_SUPPORT_PROPERTY_ESCAPING')
--supports-method-validation-level=PARAM
Controls the level of validation performed on the supports method of Change classes. Options are OFF, WARN, FAIL.
DEFAULT: WARN
(defaults file: 'liquibase.supportsMethodValidationLevel', environment variable: 'LIQUIBASE_SUPPORTS_METHOD_VALIDATION_LEVEL')
--suppress-liquibase-sql=PARAM
When set to true, this global property prevents DBCL and DBCLH sql from being present in console and logs during *-sql commands, such
as update-sql, rollback-sql, etc.
DEFAULT: false
(defaults file: 'liquibase.suppressLiquibaseSql', environment variable: 'LIQUIBASE_SUPPRESS_LIQUIBASE_SQL')
--trim-load-data-file-header=PARAM
If true column headers will be trimmed in case they were specified with spaces in the file.
DEFAULT: false
(defaults file: 'liquibase.trimLoadDataFileHeader', environment variable: 'LIQUIBASE_TRIM_LOAD_DATA_FILE_HEADER')
--ui-service=PARAM Changes the default UI Service Logger used by Liquibase. Options are CONSOLE or LOGGER.
DEFAULT: CONSOLE
(defaults file: 'liquibase.uiService', environment variable: 'LIQUIBASE_UI_SERVICE')
--use-procedure-schema=PARAM
If set to true (default value), createProcedure tags with a set schemaName will modify the procedure body with the given schema name.
DEFAULT: true
(defaults file: 'liquibase.useProcedureSchema', environment variable: 'LIQUIBASE_USE_PROCEDURE_SCHEMA')
-v, --version Print version information and exit
--validate-xml-changelog-files=PARAM
Will perform XSD validation of XML changelog files. When many XML changelog files are included, this validation may impact Liquibase
performance. Defaults to true.
DEFAULT: true
(defaults file: 'liquibase.validateXmlChangelogFiles', environment variable: 'LIQUIBASE_VALIDATE_XML_CHANGELOG_FILES')
Commands
calculate-checksum Calculates and prints a checksum for the changeset
changelog-sync Marks all changes as executed in the database
changelog-sync-sql Output the raw SQL used by Liquibase when running changelogSync
changelog-sync-to-tag Marks all undeployed changesets as executed, up to a tag
changelog-sync-to-tag-sql Output the raw SQL used by Liquibase when running changelogSyncToTag
checks < Policy Checks commands >
clear-checksums Clears all checksums
connect [PRO]
Tests the connection properties (url, username, password). Returns database's response, if any, with success or failure.
db-doc Generates JavaDoc documentation for the existing database and changelogs
dbcl-history [PRO]
List all rows from the Liquibase Pro 'DATABASECHANGELOGHISTORY' tracking table.
diff Outputs a description of differences. If you have a Liquibase Pro key, you can output the differences as JSON using the
--format=JSON option
diff-changelog Compare two databases to produce changesets and write them to a changelog file
drop-all Drop all database objects owned by the user
execute-sql Execute a SQL string or file
flow [PRO]
Run a series of commands contained in one or more stages, as configured in a liquibase flow-file.
future-rollback-count-sql Generates SQL to sequentially revert <count> number of changes
future-rollback-from-tag-sql Generates SQL to revert future changes up to the specified tag
future-rollback-sql Generate the raw SQL needed to rollback undeployed changes
generate-changelog Generate a changelog
history List all deployed changesets and their deployment ID
init < Init commands >
list-locks List the hostname, IP address, and timestamp of the Liquibase lock record
mark-next-changeset-ran Marks the next change you apply as executed in your database
mark-next-changeset-ran-sql Writes the SQL used to mark the next change you apply as executed in your database
release-locks Remove the Liquibase lock record from the DATABASECHANGELOG table
rollback Rollback changes made to the database based on the specific tag
rollback-count Rollback the specified number of changes made to the database
rollback-count-sql Generate the SQL to rollback the specified number of changes
rollback-one-changeset [PRO]
Rollback one changeset from the database
rollback-one-changeset-sql [PRO]
Rollback one changeset from the database
rollback-one-update [PRO]
Rollback one update from the database
rollback-one-update-sql [PRO]
Rollback one update from the database
rollback-sql Generate the SQL to rollback changes made to the database based on the specific tag
rollback-to-date Rollback changes made to the database based on the specific date
rollback-to-date-sql Generate the SQL to rollback changes made to the database based on the specific date
set-contexts [PRO]
Bulk set contexts in the changelog file
set-labels [PRO]
Bulk set labels in the changelog file
snapshot Capture the current state of the database
snapshot-reference Capture the current state of the reference database
status Generate a list of pending changesets
tag Mark the current database state with the specified tag
tag-exists Verify the existence of the specified tag
unexpected-changesets Generate a list of changesets that have been executed but are not in the current changelog
update Deploy any changes in the changelog file that have not been deployed
update-count Deploy the specified number of changes from the changelog file
update-count-sql Generate the SQL to deploy the specified number of changes
update-one-changeset [PRO]
Runs single changeset
update-one-changeset-sql [PRO]
Generates sql to run single changeset
update-sql Generate the SQL to deploy changes in the changelog which have not been deployed
update-testing-rollback Updates database, then rolls back changes before updating again. Useful for testing rollback support
update-to-tag Deploy changes from the changelog file to the specified tag
update-to-tag-sql Generate the SQL to deploy changes up to the tag
validate Validate the changelog for errors
Each argument contains the corresponding 'configuration key' in parentheses. As an alternative to passing values on the command line, these keys can be used as a
basis for configuration settings in other locations.
Available configuration locations, in order of priority:
- Command line arguments (argument name in --help)
- Java system properties (configuration key listed above)
- Environment values (env variable listed above)
- Defaults file (configuration key OR argument name)
Full documentation is available at
https://docs.liquibase.com
[root@gbase_rh7_003 liquibasegbase]#
[root@gbase_rh7_003 ~]#