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

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
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsAndrei Solntsev
 
Come Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayCome Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayJoris Kuipers
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
Introduction To Liquibase
Introduction To Liquibase Introduction To Liquibase
Introduction To Liquibase Knoldus Inc.
 
How to Migrate from Oracle to EDB Postgres
How to Migrate from Oracle to EDB PostgresHow to Migrate from Oracle to EDB Postgres
How to Migrate from Oracle to EDB PostgresAshnikbiz
 
Introducing Change Data Capture with Debezium
Introducing Change Data Capture with DebeziumIntroducing Change Data Capture with Debezium
Introducing Change Data Capture with DebeziumChengKuan Gan
 
GitLab Premium 라이선스 기능소개 - 인포그랩
GitLab Premium 라이선스 기능소개 - 인포그랩GitLab Premium 라이선스 기능소개 - 인포그랩
GitLab Premium 라이선스 기능소개 - 인포그랩InfoGrab LC
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git BasicsSreedath N S
 
Change Data Streaming Patterns for Microservices With Debezium
Change Data Streaming Patterns for Microservices With Debezium Change Data Streaming Patterns for Microservices With Debezium
Change Data Streaming Patterns for Microservices With Debezium confluent
 
GitHub - Présentation
GitHub - PrésentationGitHub - Présentation
GitHub - PrésentationDavid RIEHL
 
DB Monitoring 개념 및 활용 (박명규)
DB Monitoring 개념 및 활용 (박명규)DB Monitoring 개념 및 활용 (박명규)
DB Monitoring 개념 및 활용 (박명규)WhaTap Labs
 
Maxscale 소개 1.1.1
Maxscale 소개 1.1.1Maxscale 소개 1.1.1
Maxscale 소개 1.1.1NeoClova
 
Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Bhavya Chawla
 
Power bi premium
Power bi premiumPower bi premium
Power bi premiumIke Ellis
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema Mydbops
 
Backup and recovery in sql server database
Backup and recovery in sql server databaseBackup and recovery in sql server database
Backup and recovery in sql server databaseAnshu Maurya
 

What's hot (20)

Continuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With LiquibaseContinuous DB Changes Delivery With Liquibase
Continuous DB Changes Delivery With Liquibase
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Git hooks
Git hooksGit hooks
Git hooks
 
Come Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayCome Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with Flyway
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
Introduction To Liquibase
Introduction To Liquibase Introduction To Liquibase
Introduction To Liquibase
 
How to Migrate from Oracle to EDB Postgres
How to Migrate from Oracle to EDB PostgresHow to Migrate from Oracle to EDB Postgres
How to Migrate from Oracle to EDB Postgres
 
Introducing Change Data Capture with Debezium
Introducing Change Data Capture with DebeziumIntroducing Change Data Capture with Debezium
Introducing Change Data Capture with Debezium
 
GitLab Premium 라이선스 기능소개 - 인포그랩
GitLab Premium 라이선스 기능소개 - 인포그랩GitLab Premium 라이선스 기능소개 - 인포그랩
GitLab Premium 라이선스 기능소개 - 인포그랩
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
Change Data Streaming Patterns for Microservices With Debezium
Change Data Streaming Patterns for Microservices With Debezium Change Data Streaming Patterns for Microservices With Debezium
Change Data Streaming Patterns for Microservices With Debezium
 
GitHub - Présentation
GitHub - PrésentationGitHub - Présentation
GitHub - Présentation
 
DB Monitoring 개념 및 활용 (박명규)
DB Monitoring 개념 및 활용 (박명규)DB Monitoring 개념 및 활용 (박명규)
DB Monitoring 개념 및 활용 (박명규)
 
Maxscale 소개 1.1.1
Maxscale 소개 1.1.1Maxscale 소개 1.1.1
Maxscale 소개 1.1.1
 
Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.
 
Power bi premium
Power bi premiumPower bi premium
Power bi premium
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema
 
Backup and recovery in sql server database
Backup and recovery in sql server databaseBackup and recovery in sql server database
Backup and recovery in sql server database
 

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 發展資料庫結構