SlideShare a Scribd company logo
1 of 13
使用 Liquibase 發展資料庫結構
Liquibase is 10 years old!!
Ref: Datical DB
• 高控制性
• 無法自動判斷變更的版本
• 需要依賴人工介入
• 很難處理不同版本的資料庫轉移
• 與程式碼的耦合度高
• 可以透過不同的 dialect 處理不同的資料庫
• 只能有條件的管理變更
• 很難處理資料的變更
SQL JPA
最初的需求 (2006)
• 所有的變更都和程式碼一起保存在版本控制系統裡,
並且可以被分支與合併
• 每一個變更都可以容易的被產生,並且擁有獨一無二
的識別
• 每個資料庫知道要執行哪些變更來符合現在程式碼的
版本
Ref: Sundog Database Refactoring Tool Early Access Program Opens
最初的需求 (2016)
• 支援多種資料庫,甚至能在不同的資料庫執行相同的
程式
• 支援多個開發人員、多個分支下的並行開發
• 安全的更新資料庫結構而不必擔心資料遺失
• 追蹤資料庫的變化
Ref: Happy Birthday! Here's to 10 Years of Liquibase
支援
• Java 1.4 和 1.5
• MySQL, PostgreSQL, Oracle, Sql Server, Sybase,
DB2, Derby, HSQL, H2, Informix, Firebird, SQLite
• Command Line, Ant, Maven, Gradle, Spring-boot…
• XML, YAML, JSON, SQL
Ref: Datical DB
ChangeLog
ChangeSet
Change
1
*
1
*
必須能自動執
行
版本控制
結構
<databaseChangeLog xmlns=“…”>
<changeSet id="00000000000001" author=“steven">
<createTable tableName="user">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="varchar(100)"/>
</createTable>
<rollback>
drop table user
</rollback>
</changeSet>
</databaseChangeLog>
兩個重要的 table
• DATABASECHANGELOG
• 用來追蹤哪些 ChangeSet 已經執行
• Author、ID、File
• DATABASECHANGELOGLOCK
• 避免衝突
常用的指令
• update
• rollback
• diff
• tag
Ref: Liquibase Command Line
Best Practices
• 透過 master.xml 來管理所有的 ChangeSet
• 不更改已執行過的 ChangeSet
• 確保所有的 ChangeSet 都有 Rollback
Ref: Liquibase Best Practices
常見的問題
• ChangeSet 的主要屬性:runAlways, runOnChange,
runInTransaction 的使用
• rollback 的問題
• generateChangeLog 指令
練習資源
• Tutorial using Oracle
• http://www.liquibase.org/tutorial-using-oracle
• JCConf TW 2015 Database Continuous Integration
• https://github.com/wang-steven/jcconf-tw-2015

More Related Content

What's hot

Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsAndrei Solntsev
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developersIllia Seleznov
 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot ActuatorRowell Belen
 
ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)Mydbops
 
Continuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseContinuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseAidas Dragūnas
 
PostgreSQL Security. How Do We Think?
PostgreSQL Security. How Do We Think?PostgreSQL Security. How Do We Think?
PostgreSQL Security. How Do We Think?Ohyama Masanori
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0Olivier DASINI
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpen Gurukul
 
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamTop-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamMydbops
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentationritika1
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & ActuatorsVMware Tanzu
 
Load Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesLoad Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesSeveralnines
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 

What's hot (20)

Liquibase
LiquibaseLiquibase
Liquibase
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 
Database change management with Liquibase
Database change management with LiquibaseDatabase change management with Liquibase
Database change management with Liquibase
 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot Actuator
 
ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)
 
Continuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseContinuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With Liquibase
 
PostgreSQL Security. How Do We Think?
PostgreSQL Security. How Do We Think?PostgreSQL Security. How Do We Think?
PostgreSQL Security. How Do We Think?
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0
 
React Server Side Rendering with Next.js
React Server Side Rendering with Next.jsReact Server Side Rendering with Next.js
React Server Side Rendering with Next.js
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQL
 
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamTop-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Load Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesLoad Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - Slides
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 

Similar to 使用 Liquibase 發展資料庫結構

開放原始碼 Ch2.4 app - oss - db (ver 1.0)
開放原始碼 Ch2.4   app - oss - db (ver 1.0)開放原始碼 Ch2.4   app - oss - db (ver 1.0)
開放原始碼 Ch2.4 app - oss - db (ver 1.0)My own sweet home!
 
SQL Server 資料庫版本控管
SQL Server 資料庫版本控管SQL Server 資料庫版本控管
SQL Server 資料庫版本控管Will Huang
 
網站上線了,然後呢?
網站上線了,然後呢?網站上線了,然後呢?
網站上線了,然後呢?Kirk Chen
 
Elastic stack day-1
Elastic stack day-1Elastic stack day-1
Elastic stack day-1YI-CHING WU
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略Will Huang
 
搶救資料庫效能大作戰
搶救資料庫效能大作戰搶救資料庫效能大作戰
搶救資料庫效能大作戰Rico Chen
 
分布式系统日志处理调研
分布式系统日志处理调研分布式系统日志处理调研
分布式系统日志处理调研klandor
 
Git&Github Tutorial
Git&Github TutorialGit&Github Tutorial
Git&Github TutorialTing Wen Su
 
03.wls depoly jdbc
03.wls depoly jdbc03.wls depoly jdbc
03.wls depoly jdbcMeng He
 
Rest与面向资源的web开发
Rest与面向资源的web开发Rest与面向资源的web开发
Rest与面向资源的web开发topgeek
 
Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2redhat9
 
Azure Data Lake 簡介
Azure Data Lake 簡介Azure Data Lake 簡介
Azure Data Lake 簡介Herman Wu
 
Langchain and Azure ML and Open AI
Langchain and Azure ML and Open AILangchain and Azure ML and Open AI
Langchain and Azure ML and Open AIKo Ko
 
Mr&ueh数据库方面
Mr&ueh数据库方面Mr&ueh数据库方面
Mr&ueh数据库方面Tianwei Liu
 
Nosql三步曲
Nosql三步曲Nosql三步曲
Nosql三步曲84zhu
 

Similar to 使用 Liquibase 發展資料庫結構 (20)

開放原始碼 Ch2.4 app - oss - db (ver 1.0)
開放原始碼 Ch2.4   app - oss - db (ver 1.0)開放原始碼 Ch2.4   app - oss - db (ver 1.0)
開放原始碼 Ch2.4 app - oss - db (ver 1.0)
 
SQL Server 資料庫版本控管
SQL Server 資料庫版本控管SQL Server 資料庫版本控管
SQL Server 資料庫版本控管
 
File api
File apiFile api
File api
 
File api
File apiFile api
File api
 
網站上線了,然後呢?
網站上線了,然後呢?網站上線了,然後呢?
網站上線了,然後呢?
 
Elastic stack day-1
Elastic stack day-1Elastic stack day-1
Elastic stack day-1
 
20160420 - git intro
20160420 - git intro20160420 - git intro
20160420 - git intro
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略
 
搶救資料庫效能大作戰
搶救資料庫效能大作戰搶救資料庫效能大作戰
搶救資料庫效能大作戰
 
分布式系统日志处理调研
分布式系统日志处理调研分布式系统日志处理调研
分布式系统日志处理调研
 
Git&Github Tutorial
Git&Github TutorialGit&Github Tutorial
Git&Github Tutorial
 
Oracle 資料庫建立
Oracle 資料庫建立Oracle 資料庫建立
Oracle 資料庫建立
 
Mesos intro
Mesos introMesos intro
Mesos intro
 
03.wls depoly jdbc
03.wls depoly jdbc03.wls depoly jdbc
03.wls depoly jdbc
 
Rest与面向资源的web开发
Rest与面向资源的web开发Rest与面向资源的web开发
Rest与面向资源的web开发
 
Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2
 
Azure Data Lake 簡介
Azure Data Lake 簡介Azure Data Lake 簡介
Azure Data Lake 簡介
 
Langchain and Azure ML and Open AI
Langchain and Azure ML and Open AILangchain and Azure ML and Open AI
Langchain and Azure ML and Open AI
 
Mr&ueh数据库方面
Mr&ueh数据库方面Mr&ueh数据库方面
Mr&ueh数据库方面
 
Nosql三步曲
Nosql三步曲Nosql三步曲
Nosql三步曲
 

使用 Liquibase 發展資料庫結構