如何查看mysql的changelog_Liquibase 数据库版本管理工具:2.changelog 详解

上篇文章简单介绍了 Liquibase 的安装与使用,接下来开始对 Liquibase 进行一步一步的详解。

传送门:九人稚:Liquibase 数据库版本管理工具:1.安装​zhuanlan.zhihu.com3162ee4b00aba61df398da237b062bbc.png

1.什么是changelog?

上期文章中提到 changelog 是 Liquibase 进行版本管理的核心文件。

这里贴一个官方介绍:The root of all Liquibase changes is the changelog file. Liquibase uses a changelog to list all changes, in order, made to your database. Think of it as a ledger. It is a file that contains a record of all your database changes (changesets). Liquibase uses this changelog record to audit your database and execute any changes not yet applied to your database.

changelog 是 Liquibase 版本控制的核心,Liquibase 通过有序的 changelog 罗列你对数据库的更改,你可以把它想象成为一个账本,包含你对数据库所有操作的文件。

Liquibase 使用这个变更日志来审计你的数据库,并执行任何还没有应用到目标数据库的变更操作

简而言之就是一个日志文件,可以理解成 MySql 的 binlog 重做日志,Hadoop 的 NameNode 日志,提供重现步骤

2. changelog 的格式

Liquibase 提供的 changelog 格式有5种:SQL

XML

JSON

YAML

Other

其中建议使用的是 XML ,其次是 YAML,原因是可读性高。

2.1 XML 格式

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"

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsdhttp://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

2.2 YAML 格式

使用 JSON 需要下载:snakeyaml-1.12.jar ,并加入到 classpath 中

databaseChangeLog:- changeSet:id:1author:nvoxlandchanges:- createTable


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部