SlideShare a Scribd company logo
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
2Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Howdy, I’m Blaine Carter
Oracle Developer Advocate for Open Source
Oracle Corporation
Email: blaine.carter@oracle.com
Twitter: @OraBlaineOS
Blog: learncodeshare.net
Team: community.oracle.com/docs/DOC-917690
3Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Database Script Management – The Hard Way
MasterCreate directory:
RunAllVer5.sql
CreateLB_Groups.sql
CreateLB_People.sql
LoadLB_GroupsData.sql
Update4to5 directory:
UpdateAllVer4to5.sql
AddColGroupsRules.sql
AddColPeopleFavorite_color.sql
Problems:
Which script has been run?
Update or Rollback to a specific version?
Test data? → LoadTestData.sql?
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 4
Leveraging Open Source for Oracle Database Development
Liquibase
Cross platform database change
management.
http://www.liquibase.org/
https://github.com/liquibase/liquibase
Blaine Carter
5Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Version Control / Change Management
Basics:
● Track changes.
● Rollback / Switch to a specific revision.
● Branch / Merge - http://www.liquibase.org/development/branches.html
● Diffs
6Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
What is Liquibase?
Liquibase is change management for your database.
● Database changes are made using changeSets.
● When you run an update, the changeSets are run in order.
● Liquibase tracks what has been run, when and who ran it.
● You can roll back to a specific version.
● Populate default and/or test data.
● Contexts - http://www.liquibase.org/documentation/contexts.html
● Diffs - http://www.liquibase.org/documentation/diff.html
● Documentation - http://www.liquibase.org/documentation/dbdoc.html
● SQL Output - http://www.liquibase.org/documentation/sql_output.html
● Offline - http://www.liquibase.org/documentation/offline.html
7Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
How Does It Work?
8Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Changelog Master
{
"databaseChangeLog": [
{"include": {"file":"changelog/db.changelog-1.json"}}
]
}
9Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
ChangeSet
{"databaseChangeLog": [
{"preConditions": [{
"runningAs": {
"username": "lb_demo"
}
}]
},
{"changeSet": {
"id": "1",
"author": "BlaineCarter",
"changes": [
{"createTable": {
"tableName": "lb_person",
"columns": [
{"column": {
"name": "id",
"type": "int",
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"nullable": false
…...
10Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Java Command Line
java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar --driver=oracle.jdbc.OracleDriver
--classpath="/usr/lib/oracle/12.1/client64/lib/ojdbc7.jar" --url=jdbc:oracle:thin:lb_demo/dd@dbaccess
--changeLogFile=changelog/db.changelog-master.json updateSQL >> output.sql
options
--logLevel=DEBUG --logFile=liquibase.logFile
$JAVA_OPTS is used for my Oracle Exadata Express cloud connection.
11Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Properties File (liquibase.properties)
driver: oracle.jdbc.OracleDriver
classpath: /usr/lib/oracle/12.1/client64/lib/ojdbc7.jar
url: jdbc:oracle:thin:lb_demo/dd@dbaccess
changeLogFile: changelog/db.changelog-master.json
12Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Liquibase Best Recommended Practices
http://www.liquibase.org/bestpractices.html
Ignore the directory structure I’m using in the demo’s.
13Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Software We’ll Be Using
•
SQL Developer
•
Oracle Exadata Express Cloud Database or Virtual Box
•
Liquibase - http://www.liquibase.org
14Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Install
Download - http://www.liquibase.org/download/index.html
Install – It's just Java, extract it and go.
15Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Enough blah blah, let's see it.
16Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Create Changelog and ChangeSet Files
Changelog Example:
http://www.liquibase.org/quickstart.html - step 1
Changeset Example:
http://www.liquibase.org/quickstart.html - step 2
Recommended to only perform one change per Change set,
but you can do more if you need.
17Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Run It
http://www.liquibase.org/quickstart.html - step 3
Jar File:
java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar updateSQL
Shell Script:
/opt/liquibase/liquibase updateSQL
Batch File:
c:toolsliquibaseliquibase.bat updateSQL
Put the Liquibase directory in your path and run it:
liquibase update
The shell script / batch files use the same JAVA_OPTS environment variable for my cloud connection.
18Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Rollback X Number of Change Sets
Warning: Rolling back anything in the database can be tricky. Be very careful if you ever do this in
Production.
liquibase rollbackCount 1
19Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Tag a Changeset
You can tag a changeset in the file:
"changeSet": {
"id": "1",
"author": "BlaineCarter",
"tagDatabase": {"tag":"ver-1"},
"changes": [
You can also use the command line:
liquibase tag ver-1
20Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Rollback to Tag
http://www.liquibase.org/documentation/rollback.html
liquibase rollback ver-1
Other Options:
http://www.liquibase.org/documentation/command_line.html
21Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Load Data From a File
"changes": [
{
"loadData": {
"file": "changelog/groups.csv",
"schemaName": "lb_demo",
"tableName": "lb_groups"
}
}]
groups.csv
name,description
Trucks,People who like trucks
Rockets,People who like rockets
Horses,People who like horses
Snakes,People who like snakes
22Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Insert Data
"changes": [
{
"insert": {
"schemaName": "lb_demo",
"tableName": "lb_people",
"columns": [
{
"column": {
"name": "firstname",
"value": "Bob"
}
},
{
"column": {
"name": "lastname",
"value": "Trucker"
}
}
...
23Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Context Test
In the change set:
"changeSet": {
"id": "loadData-example",
"author": "liquibase-docs",
"context": "test",
Liquibase.properties
contexts: !test
Command Line overrides the properties file:
liquibase --contexts=test update
Context vs Labels
http://www.liquibase.org/2014/11/contexts-vs-labels.html
24Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Data Changes Are NOT Automatically Rolled Back.
Define your own Rollback
{
"rollback": {
"delete": {
"tableName": "lb_people"
}
}
}
25Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Diff
http://www.liquibase.org/documentation/diff.html
Command Line:
liquibase.sh --driver=oracle.jdbc.OracleDriver 
--url=jdbc:oracle:thin:lb_demo/dd@unknownDB 
diff 
--referenceUrl=jdbc:oracle:thin:lb_demo/dd@goodDB
Liquibase.properties:
referenceUrl: jdbc:oracle:thin:lb_diff_demo/dd@dbaccess
26Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Generate Changelog (Reverse Engineer)
http://www.liquibase.org/documentation/generating_changelogs.html
Note that this command currently has some limitations. It does not export the following types of objects:
Stored procedures, functions, packages & Triggers
liquibase --changeLogFile=generated.json generateChangeLog
27Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Review The Output
The output won’t be perfect.
Generated by update:
id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL
Generated by generateChangeLog:
ID NUMBER(*, 0) DEFAULT "LB_DEMO"."ISEQ$$_69966".nextval NOT NULL
28Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
DBDoc
http://www.liquibase.org/documentation/dbdoc.html
liquibase DBDoc docs
29Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Extensions / Plugins
https://liquibase.jira.com/wiki/display/CONTRIB/LiquiBase+Extensions+Portal
30Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
We Can Make It Better
•
Github
– Repo
– Fork
– Change
– Pull Request
– Not just code
•
https://github.com/liquibase/liquibase
•
https://github.com/liquibase/liquibase/blob/master/LICENSE.txt
31Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Thank You, Now Go Out And Try It.
Oracle Developer Advocate for Open Source
Oracle Corporation
Email: blaine.carter@oracle.com
Twitter: @OraBlaineOS
Blog: learncodeshare.net
Team: community.oracle.com/docs/DOC-917690
32Copyright © 2016 Oracle and/or its affiliates. All rights reserved.
Commands Used For The Demo (by slide number)
#17
liquibase updateSQL
liquibase update
#18
liquibase rollbackCount 1
liquibase update
#19
liquibase update
liquibase tag myCoolTag
#20
liquibase rollback ver-1
liquibase update
#21
liquibase update
#23
liquibase --contexts=test update
#24
liquibase rollbackCount 2
liquibase rollbackCount 1
liquibase --contexts=test rollbackCount 2
liquibase --contexts=test update
#25
liquibase diff
liquibase --diffTypes=tables,columns diff
liquibase diffChangeLog
#26
liquibase --changeLogFile=generated.json generateChangeLog
#28
liquibase dropAll
liquibase DBDoc docs
liquibase update
liquibase DBDoc docs

More Related Content

What's hot (20)

PPT
Simplify your integrations with Apache Camel
Kenneth Peeples
 
PPTX
Play + scala + reactive mongo
Max Kremer
 
PPTX
Learn you some Ansible for great good!
David Lapsley
 
PDF
Play framework
Andrew Skiba
 
PDF
Apache Camel Introduction & What's in the box
Claus Ibsen
 
PDF
Apache Camel - The integration library
Claus Ibsen
 
PDF
GitBucket: The perfect Github clone by Scala
takezoe
 
KEY
DjangoCon 2010 Scaling Disqus
zeeg
 
PDF
Play Framework and Activator
Kevin Webber
 
PPT
Introduction to Play Framework
Warren Zhou
 
PPTX
Introduction to Apache Camel
Claus Ibsen
 
PPTX
Why Play Framework is fast
Legacy Typesafe (now Lightbend)
 
PDF
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
PPTX
Java Play RESTful ebean
Faren faren
 
PPTX
Java Play Restful JPA
Faren faren
 
PDF
Node.js vs Play Framework
Yevgeniy Brikman
 
KEY
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
Puppet
 
ODP
Getting Started with Apache Camel - Devconf Conference - February 2013
Claus Ibsen
 
PPT
Integration made easy with Apache Camel
Rosen Spasov
 
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
Simplify your integrations with Apache Camel
Kenneth Peeples
 
Play + scala + reactive mongo
Max Kremer
 
Learn you some Ansible for great good!
David Lapsley
 
Play framework
Andrew Skiba
 
Apache Camel Introduction & What's in the box
Claus Ibsen
 
Apache Camel - The integration library
Claus Ibsen
 
GitBucket: The perfect Github clone by Scala
takezoe
 
DjangoCon 2010 Scaling Disqus
zeeg
 
Play Framework and Activator
Kevin Webber
 
Introduction to Play Framework
Warren Zhou
 
Introduction to Apache Camel
Claus Ibsen
 
Why Play Framework is fast
Legacy Typesafe (now Lightbend)
 
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
Java Play RESTful ebean
Faren faren
 
Java Play Restful JPA
Faren faren
 
Node.js vs Play Framework
Yevgeniy Brikman
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
Puppet
 
Getting Started with Apache Camel - Devconf Conference - February 2013
Claus Ibsen
 
Integration made easy with Apache Camel
Rosen Spasov
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 

Viewers also liked (20)

PDF
Building a Distributed & Automated Open Source Program at Netflix
All Things Open
 
PDF
BFFs: UX & SEO Partnering to Design Successful Products
All Things Open
 
PDF
Contribution & Confidence
All Things Open
 
ODP
Civic Hacking 201: Successful techniques for civic tech
All Things Open
 
PDF
Marketing is not all fluff; engineering is not all math
All Things Open
 
PDF
Modern Container Orchestration (Without Breaking the Bank)
All Things Open
 
PDF
Scaling Your Logging Infrastructure With Syslog-NG
All Things Open
 
PDF
CSS Grid Layout
All Things Open
 
PDF
DevOps for Managers
All Things Open
 
PDF
The Datacenter Network You Wish You Had: It's yours for the taking.
All Things Open
 
PDF
Data Encryption at Rest
All Things Open
 
PDF
Develop and Deploy Cloud-Native Apps as Resilient Microservice Architectures
All Things Open
 
PDF
Netflix and Containers: Not Stranger Things
All Things Open
 
PPTX
Version Control meets Database Control
DBmaestro - Database DevOps
 
KEY
Database version control DPC version
Harrie Verveer
 
KEY
Database version control - pf congres version
Harrie Verveer
 
PDF
Database version control without pain - the PHP Barcelona version
Harrie Verveer
 
PPTX
Database Change Management
Kate Semizhon
 
PDF
Database version control without pain - the PHPNW10 version
Harrie Verveer
 
PPTX
Database versioning with liquibase
Return on Intelligence
 
Building a Distributed & Automated Open Source Program at Netflix
All Things Open
 
BFFs: UX & SEO Partnering to Design Successful Products
All Things Open
 
Contribution & Confidence
All Things Open
 
Civic Hacking 201: Successful techniques for civic tech
All Things Open
 
Marketing is not all fluff; engineering is not all math
All Things Open
 
Modern Container Orchestration (Without Breaking the Bank)
All Things Open
 
Scaling Your Logging Infrastructure With Syslog-NG
All Things Open
 
CSS Grid Layout
All Things Open
 
DevOps for Managers
All Things Open
 
The Datacenter Network You Wish You Had: It's yours for the taking.
All Things Open
 
Data Encryption at Rest
All Things Open
 
Develop and Deploy Cloud-Native Apps as Resilient Microservice Architectures
All Things Open
 
Netflix and Containers: Not Stranger Things
All Things Open
 
Version Control meets Database Control
DBmaestro - Database DevOps
 
Database version control DPC version
Harrie Verveer
 
Database version control - pf congres version
Harrie Verveer
 
Database version control without pain - the PHP Barcelona version
Harrie Verveer
 
Database Change Management
Kate Semizhon
 
Database version control without pain - the PHPNW10 version
Harrie Verveer
 
Database versioning with liquibase
Return on Intelligence
 
Ad

Similar to Leveraging Open Source for Database Development: Database Version Control with Liquibase (20)

PDF
Liquibase - Open Source version control for your database
Blaine Carter
 
PDF
Marcin Szałowicz - MySQL Workbench
Women in Technology Poland
 
PDF
MySQL Document Store
Mario Beck
 
PPTX
Change Management for Oracle Database with SQLcl
Jeff Smith
 
PPTX
OUGLS 2016: Guided Tour On The MySQL Source Code
Georgi Kodinov
 
PDF
MySQL Shell: The DevOps Tool for MySQL
Miguel Araújo
 
PPTX
My sql8 innodb_cluster
Mysql User Camp
 
PDF
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
Frederic Descamps
 
PDF
20151010 my sq-landjavav2a
Ivan Ma
 
PPTX
Configuration for Java EE: Config JSR and Tamaya
Dmitry Kornilov
 
PPTX
Oracle Database Management REST API
Jeff Smith
 
PPTX
Oracle database 12c_and_DevOps
Maria Colgan
 
PDF
MySQL Shell for DBAs
Frederic Descamps
 
PDF
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Olivier DASINI
 
PDF
Java Cloud and Container Ready
CodeOps Technologies LLP
 
PDF
Jmorrow rtv den_auto_config_rapidclone
Mlx Le
 
PDF
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Timothy Schubert
 
PDF
Reducing the Risks of Migrating Off Oracle
EDB
 
PDF
20190713_MySQL開発最新動向
Machiko Ikoma
 
PDF
State of The Dolphin - May 2021
Frederic Descamps
 
Liquibase - Open Source version control for your database
Blaine Carter
 
Marcin Szałowicz - MySQL Workbench
Women in Technology Poland
 
MySQL Document Store
Mario Beck
 
Change Management for Oracle Database with SQLcl
Jeff Smith
 
OUGLS 2016: Guided Tour On The MySQL Source Code
Georgi Kodinov
 
MySQL Shell: The DevOps Tool for MySQL
Miguel Araújo
 
My sql8 innodb_cluster
Mysql User Camp
 
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
Frederic Descamps
 
20151010 my sq-landjavav2a
Ivan Ma
 
Configuration for Java EE: Config JSR and Tamaya
Dmitry Kornilov
 
Oracle Database Management REST API
Jeff Smith
 
Oracle database 12c_and_DevOps
Maria Colgan
 
MySQL Shell for DBAs
Frederic Descamps
 
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Olivier DASINI
 
Java Cloud and Container Ready
CodeOps Technologies LLP
 
Jmorrow rtv den_auto_config_rapidclone
Mlx Le
 
Suffering from Chronic Patching Pain? Get Relief with Fleet Maintenance [CON6...
Timothy Schubert
 
Reducing the Risks of Migrating Off Oracle
EDB
 
20190713_MySQL開発最新動向
Machiko Ikoma
 
State of The Dolphin - May 2021
Frederic Descamps
 
Ad

More from All Things Open (20)

PDF
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
PPTX
Big Data on a Small Budget: Scalable Data Visualization for the Rest of Us - ...
All Things Open
 
PDF
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
PDF
Let's Create a GitHub Copilot Extension! - Nick Taylor, Pomerium
All Things Open
 
PDF
Leveraging Pre-Trained Transformer Models for Protein Function Prediction - T...
All Things Open
 
PDF
Gen AI: AI Agents - Making LLMs work together in an organized way - Brent Las...
All Things Open
 
PDF
You Don't Need an AI Strategy, But You Do Need to Be Strategic About AI - Jes...
All Things Open
 
PPTX
DON’T PANIC: AI IS COMING – The Hitchhiker’s Guide to AI - Mark Hinkle, Perip...
All Things Open
 
PDF
Fine-Tuning Large Language Models with Declarative ML Orchestration - Shivay ...
All Things Open
 
PDF
Leveraging Knowledge Graphs for RAG: A Smarter Approach to Contextual AI Appl...
All Things Open
 
PPTX
Artificial Intelligence Needs Community Intelligence - Sriram Raghavan, IBM R...
All Things Open
 
PDF
Don't just talk to AI, do more with AI: how to improve productivity with AI a...
All Things Open
 
PPTX
Open-Source GenAI vs. Enterprise GenAI: Navigating the Future of AI Innovatio...
All Things Open
 
PDF
The Death of the Browser - Rachel-Lee Nabors, AgentQL
All Things Open
 
PDF
Making Operating System updates fast, easy, and safe
All Things Open
 
PDF
Reshaping the landscape of belonging to transform community
All Things Open
 
PDF
The Unseen, Underappreciated Security Work Your Maintainers May (or may not) ...
All Things Open
 
PDF
Integrating Diversity, Equity, and Inclusion into Product Design
All Things Open
 
PDF
The Open Source Ecosystem for eBPF in Kubernetes
All Things Open
 
PDF
Open Source Privacy-Preserving Metrics - Sarah Gran & Brandon Pitman
All Things Open
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
Big Data on a Small Budget: Scalable Data Visualization for the Rest of Us - ...
All Things Open
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Let's Create a GitHub Copilot Extension! - Nick Taylor, Pomerium
All Things Open
 
Leveraging Pre-Trained Transformer Models for Protein Function Prediction - T...
All Things Open
 
Gen AI: AI Agents - Making LLMs work together in an organized way - Brent Las...
All Things Open
 
You Don't Need an AI Strategy, But You Do Need to Be Strategic About AI - Jes...
All Things Open
 
DON’T PANIC: AI IS COMING – The Hitchhiker’s Guide to AI - Mark Hinkle, Perip...
All Things Open
 
Fine-Tuning Large Language Models with Declarative ML Orchestration - Shivay ...
All Things Open
 
Leveraging Knowledge Graphs for RAG: A Smarter Approach to Contextual AI Appl...
All Things Open
 
Artificial Intelligence Needs Community Intelligence - Sriram Raghavan, IBM R...
All Things Open
 
Don't just talk to AI, do more with AI: how to improve productivity with AI a...
All Things Open
 
Open-Source GenAI vs. Enterprise GenAI: Navigating the Future of AI Innovatio...
All Things Open
 
The Death of the Browser - Rachel-Lee Nabors, AgentQL
All Things Open
 
Making Operating System updates fast, easy, and safe
All Things Open
 
Reshaping the landscape of belonging to transform community
All Things Open
 
The Unseen, Underappreciated Security Work Your Maintainers May (or may not) ...
All Things Open
 
Integrating Diversity, Equity, and Inclusion into Product Design
All Things Open
 
The Open Source Ecosystem for eBPF in Kubernetes
All Things Open
 
Open Source Privacy-Preserving Metrics - Sarah Gran & Brandon Pitman
All Things Open
 

Recently uploaded (20)

PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 

Leveraging Open Source for Database Development: Database Version Control with Liquibase

  • 1. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
  • 2. 2Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Howdy, I’m Blaine Carter Oracle Developer Advocate for Open Source Oracle Corporation Email: [email protected] Twitter: @OraBlaineOS Blog: learncodeshare.net Team: community.oracle.com/docs/DOC-917690
  • 3. 3Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Database Script Management – The Hard Way MasterCreate directory: RunAllVer5.sql CreateLB_Groups.sql CreateLB_People.sql LoadLB_GroupsData.sql Update4to5 directory: UpdateAllVer4to5.sql AddColGroupsRules.sql AddColPeopleFavorite_color.sql Problems: Which script has been run? Update or Rollback to a specific version? Test data? → LoadTestData.sql?
  • 4. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 4 Leveraging Open Source for Oracle Database Development Liquibase Cross platform database change management. http://www.liquibase.org/ https://github.com/liquibase/liquibase Blaine Carter
  • 5. 5Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Version Control / Change Management Basics: ● Track changes. ● Rollback / Switch to a specific revision. ● Branch / Merge - http://www.liquibase.org/development/branches.html ● Diffs
  • 6. 6Copyright © 2016 Oracle and/or its affiliates. All rights reserved. What is Liquibase? Liquibase is change management for your database. ● Database changes are made using changeSets. ● When you run an update, the changeSets are run in order. ● Liquibase tracks what has been run, when and who ran it. ● You can roll back to a specific version. ● Populate default and/or test data. ● Contexts - http://www.liquibase.org/documentation/contexts.html ● Diffs - http://www.liquibase.org/documentation/diff.html ● Documentation - http://www.liquibase.org/documentation/dbdoc.html ● SQL Output - http://www.liquibase.org/documentation/sql_output.html ● Offline - http://www.liquibase.org/documentation/offline.html
  • 7. 7Copyright © 2016 Oracle and/or its affiliates. All rights reserved. How Does It Work?
  • 8. 8Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Changelog Master { "databaseChangeLog": [ {"include": {"file":"changelog/db.changelog-1.json"}} ] }
  • 9. 9Copyright © 2016 Oracle and/or its affiliates. All rights reserved. ChangeSet {"databaseChangeLog": [ {"preConditions": [{ "runningAs": { "username": "lb_demo" } }] }, {"changeSet": { "id": "1", "author": "BlaineCarter", "changes": [ {"createTable": { "tableName": "lb_person", "columns": [ {"column": { "name": "id", "type": "int", "autoIncrement": true, "constraints": { "primaryKey": true, "nullable": false …...
  • 10. 10Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Java Command Line java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar --driver=oracle.jdbc.OracleDriver --classpath="/usr/lib/oracle/12.1/client64/lib/ojdbc7.jar" --url=jdbc:oracle:thin:lb_demo/dd@dbaccess --changeLogFile=changelog/db.changelog-master.json updateSQL >> output.sql options --logLevel=DEBUG --logFile=liquibase.logFile $JAVA_OPTS is used for my Oracle Exadata Express cloud connection.
  • 11. 11Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Properties File (liquibase.properties) driver: oracle.jdbc.OracleDriver classpath: /usr/lib/oracle/12.1/client64/lib/ojdbc7.jar url: jdbc:oracle:thin:lb_demo/dd@dbaccess changeLogFile: changelog/db.changelog-master.json
  • 12. 12Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Liquibase Best Recommended Practices http://www.liquibase.org/bestpractices.html Ignore the directory structure I’m using in the demo’s.
  • 13. 13Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Software We’ll Be Using • SQL Developer • Oracle Exadata Express Cloud Database or Virtual Box • Liquibase - http://www.liquibase.org
  • 14. 14Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Install Download - http://www.liquibase.org/download/index.html Install – It's just Java, extract it and go.
  • 15. 15Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Enough blah blah, let's see it.
  • 16. 16Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Create Changelog and ChangeSet Files Changelog Example: http://www.liquibase.org/quickstart.html - step 1 Changeset Example: http://www.liquibase.org/quickstart.html - step 2 Recommended to only perform one change per Change set, but you can do more if you need.
  • 17. 17Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Run It http://www.liquibase.org/quickstart.html - step 3 Jar File: java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar updateSQL Shell Script: /opt/liquibase/liquibase updateSQL Batch File: c:toolsliquibaseliquibase.bat updateSQL Put the Liquibase directory in your path and run it: liquibase update The shell script / batch files use the same JAVA_OPTS environment variable for my cloud connection.
  • 18. 18Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Rollback X Number of Change Sets Warning: Rolling back anything in the database can be tricky. Be very careful if you ever do this in Production. liquibase rollbackCount 1
  • 19. 19Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Tag a Changeset You can tag a changeset in the file: "changeSet": { "id": "1", "author": "BlaineCarter", "tagDatabase": {"tag":"ver-1"}, "changes": [ You can also use the command line: liquibase tag ver-1
  • 20. 20Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Rollback to Tag http://www.liquibase.org/documentation/rollback.html liquibase rollback ver-1 Other Options: http://www.liquibase.org/documentation/command_line.html
  • 21. 21Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Load Data From a File "changes": [ { "loadData": { "file": "changelog/groups.csv", "schemaName": "lb_demo", "tableName": "lb_groups" } }] groups.csv name,description Trucks,People who like trucks Rockets,People who like rockets Horses,People who like horses Snakes,People who like snakes
  • 22. 22Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Insert Data "changes": [ { "insert": { "schemaName": "lb_demo", "tableName": "lb_people", "columns": [ { "column": { "name": "firstname", "value": "Bob" } }, { "column": { "name": "lastname", "value": "Trucker" } } ...
  • 23. 23Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Context Test In the change set: "changeSet": { "id": "loadData-example", "author": "liquibase-docs", "context": "test", Liquibase.properties contexts: !test Command Line overrides the properties file: liquibase --contexts=test update Context vs Labels http://www.liquibase.org/2014/11/contexts-vs-labels.html
  • 24. 24Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Data Changes Are NOT Automatically Rolled Back. Define your own Rollback { "rollback": { "delete": { "tableName": "lb_people" } } }
  • 25. 25Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Diff http://www.liquibase.org/documentation/diff.html Command Line: liquibase.sh --driver=oracle.jdbc.OracleDriver --url=jdbc:oracle:thin:lb_demo/dd@unknownDB diff --referenceUrl=jdbc:oracle:thin:lb_demo/dd@goodDB Liquibase.properties: referenceUrl: jdbc:oracle:thin:lb_diff_demo/dd@dbaccess
  • 26. 26Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Generate Changelog (Reverse Engineer) http://www.liquibase.org/documentation/generating_changelogs.html Note that this command currently has some limitations. It does not export the following types of objects: Stored procedures, functions, packages & Triggers liquibase --changeLogFile=generated.json generateChangeLog
  • 27. 27Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Review The Output The output won’t be perfect. Generated by update: id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL Generated by generateChangeLog: ID NUMBER(*, 0) DEFAULT "LB_DEMO"."ISEQ$$_69966".nextval NOT NULL
  • 28. 28Copyright © 2016 Oracle and/or its affiliates. All rights reserved. DBDoc http://www.liquibase.org/documentation/dbdoc.html liquibase DBDoc docs
  • 29. 29Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Extensions / Plugins https://liquibase.jira.com/wiki/display/CONTRIB/LiquiBase+Extensions+Portal
  • 30. 30Copyright © 2016 Oracle and/or its affiliates. All rights reserved. We Can Make It Better • Github – Repo – Fork – Change – Pull Request – Not just code • https://github.com/liquibase/liquibase • https://github.com/liquibase/liquibase/blob/master/LICENSE.txt
  • 31. 31Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Thank You, Now Go Out And Try It. Oracle Developer Advocate for Open Source Oracle Corporation Email: [email protected] Twitter: @OraBlaineOS Blog: learncodeshare.net Team: community.oracle.com/docs/DOC-917690
  • 32. 32Copyright © 2016 Oracle and/or its affiliates. All rights reserved. Commands Used For The Demo (by slide number) #17 liquibase updateSQL liquibase update #18 liquibase rollbackCount 1 liquibase update #19 liquibase update liquibase tag myCoolTag #20 liquibase rollback ver-1 liquibase update #21 liquibase update #23 liquibase --contexts=test update #24 liquibase rollbackCount 2 liquibase rollbackCount 1 liquibase --contexts=test rollbackCount 2 liquibase --contexts=test update #25 liquibase diff liquibase --diffTypes=tables,columns diff liquibase diffChangeLog #26 liquibase --changeLogFile=generated.json generateChangeLog #28 liquibase dropAll liquibase DBDoc docs liquibase update liquibase DBDoc docs