点击 Liquibase安装包 下载,如果下载慢或者无法下载,可以使用 Liquibase安装包代理链接
添加你自己本地的liquibase安装地址
建议电脑重启后,再测试
输入liquibase --help
,显示如下内容,则安装成功
Liquibase 是一种数据库架构更改管理解决方案,使您能够从开发到生产更快、更安全地修订和发布数据库更改,Liquibase可以 使用 SQL、XML、JSON 和 YAML 更改数据库。
例如(以xml文件和postgresql数据库为例):
如果需要查看别的数据库配置文件怎么写,请参考链接
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
<changeSet id="1" author="Liquibase">
<createTable tableName="test_table">
<column name="test_id" type="int">
<constraints primaryKey="true"/>
column>
<column name="test_column" type="varchar"/>
createTable>
changeSet>
databaseChangeLog>
init copy:
子命令将项目文件从源目录复制到目标目录。init project:
该子命令查找或创建包含更改日志和 Liquibase 属性文件的项目文件夹,并提供一个示例 H2 数据库以帮助您入门init start-h2:
该子命令启动 Liquibase 安装包中包含的内存中 H2 数据库drop-all:
drop-all删除用户拥有的所有数据库对象。update
:根据路径中的配置文件更新diff:
将相同类型或不同类型的两个数据库相互比较必须配置liquibase.properties文件中的以下配置
#### Enter the Target database 'url' information ####
liquibase.command.url=jdbc:postgresql://172.29.234.114:5432/plm-test-liquibase
# Enter the username for your Target database.
liquibase.command.username: postgres
# Enter the password for your Target database.
liquibase.command.password: 123456
#### Enter the Source Database 'referenceUrl' information ####
## The source database is the baseline or reference against which your target database is compared for diff/diffchangelog commands.
# Enter URL for the source database
liquibase.command.referenceUrl: jdbc:postgresql://172.29.234.114:5432/plm-test
# Enter the username for your source database
liquibase.command.referenceUsername: postgres
# Enter the password for your source database
liquibase.command.referencePassword: 123456