liquibase学习记录

1.参考资料地址

2.安装

2.1 下载安装包

点击 Liquibase安装包 下载,如果下载慢或者无法下载,可以使用 Liquibase安装包代理链接

2.2 解压并拷贝到安装位置

在这里插入图片描述

2.3配置环境变量

在这里插入图片描述
在这里插入图片描述

添加你自己本地的liquibase安装地址
在这里插入图片描述

2.4测试是否配置成功

建议电脑重启后,再测试

输入liquibase --help,显示如下内容,则安装成功
在这里插入图片描述

3.概念

Liquibase 是一种数据库架构更改管理解决方案,使您能够从开发到生产更快、更安全地修订和发布数据库更改,Liquibase可以 使用 SQL、XML、JSON 和 YAML 更改数据库。

3.1更改文件结构

在这里插入图片描述
例如(以xml文件和postgresql数据库为例):

如果需要查看别的数据库配置文件怎么写,请参考链接

<?xml version="1.0" encoding="UTF-8"?>
<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>

4.命令

4.1 初始化

  • init copy:子命令将项目文件从源目录复制到目标目录。
  • init project:该子命令查找或创建包含更改日志和 Liquibase 属性文件的项目文件夹,并提供一个示例 H2 数据库以帮助您入门
  • init start-h2:该子命令启动 Liquibase 安装包中包含的内存中 H2 数据库

4.2更新

  • drop-all:drop-all删除用户拥有的所有数据库对象。
  • update:根据路径中的配置文件更新

4.3数据库检查

  • 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值