SlideShare una empresa de Scribd logo
1 de 28
Liquibase
Database change management
Sergii Fesenko
Software development
● We do a lot of changes during development
● We use version control system for tracking
code changes
● However, tracking DB changes is not as easy
as tracking code changes
Database development
There are many different artifacts in database:
● tables
● data, that lives in the tables
● stored procedures
● views
● triggers
● etc (DBMS specific artifacts)
What is wrong with DB?
●database has persistent state (that’s why we
use it)
●code and database must corresponds
●each developer has local environment
●we change code very often (we agile :)
Actually, these issues are Agile specific, in case of waterfall they disappears :)
What is solution?
Store DB changes in text files (DDL and DML)
and apply them manually to DB.
A lot of projects use this approach
Manual tracking DB changes
Possible issues:
● easy to lost sync between code and DB state
● hard to recover from error during development (ex: in case of applying
wrong statement to DB)
● often require to re-create DB from scratch during development
● hard to find out state of particular DB environment
● may require to support 2 versions of changes: full and incremental
What tools are available?
● Flyway
● Liquibase
● c5-db-migration
● dbdeploy
● mybatis
● MIGRATEdb
● migrate4j
● dbmaintain
● AutoPatch
What makes liquibase different?
● DDL abstraction DSL
● Support for different changelog format
○ build-in: XML, YAML, JSON and SQL
○community-managed: groovy and closure
● Over 30 built-in database refactorings
● Rollback database changes feature
● Database diff report
● Extensibility
Liquibase major concepts
●Changelog file
●Changeset
●Changes
●Preconditions
●Contexts
Liquibase changelog file
The root of all Liquibase changes is the
databaseChangeLog file.
<databaseChangeLog>
<changeSet id="1" ...>
...
</changeSet>
<changeSet id="2" ...>
...
</changeSet>
</databaseChangeLog>
Liquibase changelog file
It is possible to break up changelogs into
multiple manageable pieces
<databaseChangeLog>
<include file="src/db/tables.xml"/>
<include file="src/db/views.xml"/>
<include file="src/db/data.xml"/>
...
</databaseChangeLog>
Liquibase changeset
Changeset is a group of changes
Liquibase attempts to execute each changeSet
in a transaction that is committed at the end, or
rolled back if there is an error.
Liquibase changeset
<databaseChangeLog>
<!-- id, author and current file name must be unique -->
<changeSet id="1" author=”sfesenko” >
<comment>Sample of changeset</comment> <!-- comment is optional -->
<change .. /> <!-- will be explained later -->
<!-- rollback is a changeset that must be executed in order to “cancel” current changeset --
>
<rollback>
<change .. />
</rollback>
</changeSet>
Liquibase changeset
<changeSet id="1" author=”sfesenko” runAlways="true"> <!-- false by default -->
…
</changeset>
<changeSet id="2" author=”sfesenko” runOnChange="true"> <!-- false by default -->
…
</changeset>
<changeSet id="3" author=”sfesenko” failOnError="false"> <!-- true by default -->
…
</changeset>
Useful for views, triggers, stored procedures
Liquibase changeset preconditions
Both changelog and changeset may have precondition - assertion, that will be
evaluated before execution of changeset.
Available preconditions:
● check for dbms type
● check for current user name
● check if changeset has been executed
● check if table exists
● check if table has column
● check if view exists
● check if FK constraint exists
● check if index exists
● check if sequence exists
● check if table has primary key (or specified primary key exists)
● arbitrary sql check
Liquibase changeset preconditions
Sample of precondition usage:
<changeSet id="1" author=”sfesenko” >
<preConditions onFail="MARK_RAN">
<tableExists tableName="TEST" />
</preConditions>
<<dropTable cascadeConstraints="true" tableName=”TEST” />
</changeset>
Liquibase changeset context
It’s possible to specify for each changeset in what context it
should be run.
Context value can be specified on liquibase run.
<changeSet id="1" author=”sfesenko” context=”clear”>
<delete tableName="USERS" />
</changeset>
Liquibase change
Each changeset contains change which
describes required modification of database.
It’s possible to use DSL (recommended, dbms
independent) or SQL for defining a change.
Liquibase change
<changeSet id="1" author="sfesenko">
<createTable tableName="CURRENCY">
<column name="CURRENCY" type="varchar(12)" >
<constraints primaryKey="true"
primaryKeyName="PK_CURRENCY_CURRENCY"/>
</column>
<column name="ISO" type="java.lang.Integer" />
<column name="DECIMAL_RULES" type="varchar(12)" />
</createTable>
<sql>
CREATE TABLE CURRENCY (
CURRENCY VARCHAR2(12) NOT NULL,
ISO NUMBER(10),
DECIMAL_RULES VARCHAR2(12),
CONSTRAINT PK_CURRENCY_CURRENCY PRIMARY KEY (CURRENCY)
);
</sql>
</changeSet>
Liquibase changes/refactorings
Structural Refactorings
● Add Column
● Rename Column
● Modify Column
● Drop Column
● Alter Sequence
● Create Table
● Rename Table
● Drop Table
● Create View
● Rename View
● Drop View
● Merge Columns
● Create Stored
Procedure
Data Quality Refactorings
● Add Lookup Table
● Add Not-Null Constraint
● Remove Not-Null Constraint
● Add Unique Constraint
● Drop Unique Constraint
● Create Sequence
● Drop Sequence
● Add Auto-Increment
● Add Default Value
● Drop Default Value
Referential Integrity Refactorings
● Add Foreign Key Constraint
● Drop Foreign Key Constraint
● Drop All Foreign Key Constraints
● Add Primary Key Constraint
● Drop Primary Key Constraint
Non-Refactoring
Transformations
● Insert Data
● Load Data
● Load Update Data
● Update Data
● Delete Data
Architectural Refactorings
● Create Index
● Drop Index
● Custom Refactorings
Modifying Generated SQL
● Custom SQL
● Custom SQL File
● Custom Refactoring Class
● Execute Shell Command
How to run liquibase
On Demand
Command Line
Ant
Maven
Automated
Servlet Listener
Spring Listener
JEE CDI Listener
Java APIs
Liquibase can easily be embedded and executed through its Java APIs.
Update DB on application start
Liquibase command line
1. Create property file liquibase.property with connection
parameters:
2. Run liquibase as
./liquibase <command>
driver: oracle.jdbc.OracleDriver
classpath: ojdbc14-10.2.0.3.0.jar
url: jdbc:oracle:thin:@localhost:1521:oracle
username: SQ_BANK
password: SQ_BANK
Liquibase quickstart
1. Generate changelog from existing database
Run ./liquibase --changeLogFile=changelog.xml generateChangeLog
1. Dump data to xml file
Run ./liquibase --changeLogFile=data.xml --diffTypes=data generateChangeLog
Be ready for OutOfMemoryError
Liquibase commands
● update
● updateSQL
● validate
● status
● dropAll
● rollbackCount
● generateChangeLog
● diff
● changelogSync
○ changelogSyncSQL
● clearCheckSums
Liquibase tips and tricks
● Use one file per changeset (greatly simplified merges)
● Use convention for file names
● Use “run on change” attribute for stored procedures, views, triggers, etc
● Decide early if rollback feature will be used
● Test both incremental and full update
● Do not change “wrong” changeset - just add new one with fix
● Consider possibility of “compressing” changesets when full update became
slow
When it is good
Best case
DB Application
When it is not so good
Worst case
DB
Application
Legacy
Application
New
Application
Some other
application that
we know about
Applications
that we don’t
know about
Q & A

Más contenido relacionado

La actualidad más candente

Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsAndrei Solntsev
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a ServiceAndrew Solomon
 
Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with LiquibaseIllia Seleznov
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseLars Östling
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
Database Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDatabase Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDan Stine
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developersIllia Seleznov
 
Performance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cPerformance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cAjith Narayanan
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
Sql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and TricksSql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and TricksAndrea Allred
 

La actualidad más candente (20)

Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a Service
 
Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with Liquibase
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and Liquibase
 
Flywaydb
FlywaydbFlywaydb
Flywaydb
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
Database Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDatabase Migrations with Gradle and Liquibase
Database Migrations with Gradle and Liquibase
 
Flyway
FlywayFlyway
Flyway
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 
Performance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cPerformance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12c
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Sql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and TricksSql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and Tricks
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 

Destacado

Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your dataNeev Technologies
 
Javaland 2016 - Flyway vs. LiquiBase - Battle der Datenbankmigrationstools
Javaland 2016 - Flyway vs. LiquiBase - Battle der DatenbankmigrationstoolsJavaland 2016 - Flyway vs. LiquiBase - Battle der Datenbankmigrationstools
Javaland 2016 - Flyway vs. LiquiBase - Battle der DatenbankmigrationstoolsStephan Kaps
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flywayJonathan Holloway
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With LiquibaseTim Berglund
 
Agile Database Development with Liquibase
Agile Database Development with LiquibaseAgile Database Development with Liquibase
Agile Database Development with LiquibaseTim Berglund
 
Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibaseYoram Michaeli
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringarSqueed
 
Gitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGerger
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With LiquibaseIASA
 
Getting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydbGetting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydbGirish Bapat
 
Gitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGerger
 
Version control for PL/SQL
Version control for PL/SQLVersion control for PL/SQL
Version control for PL/SQLGerger
 
Continuous Delivery Applied
Continuous Delivery AppliedContinuous Delivery Applied
Continuous Delivery AppliedExcella
 
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...CA Technologies
 
Maven and j unit introduction
Maven and j unit introductionMaven and j unit introduction
Maven and j unit introductionSergii Fesenko
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache slingSergii Fesenko
 
Database Change Management
Database Change ManagementDatabase Change Management
Database Change ManagementDominik Hirt
 
Last Month in PHP - February 2017
Last Month in PHP - February 2017Last Month in PHP - February 2017
Last Month in PHP - February 2017Eric Poe
 
Frame switcher library
Frame switcher libraryFrame switcher library
Frame switcher libraryRoman Khachko
 

Destacado (20)

Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
 
Javaland 2016 - Flyway vs. LiquiBase - Battle der Datenbankmigrationstools
Javaland 2016 - Flyway vs. LiquiBase - Battle der DatenbankmigrationstoolsJavaland 2016 - Flyway vs. LiquiBase - Battle der Datenbankmigrationstools
Javaland 2016 - Flyway vs. LiquiBase - Battle der Datenbankmigrationstools
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
 
Agile Database Development with Liquibase
Agile Database Development with LiquibaseAgile Database Development with Liquibase
Agile Database Development with Liquibase
 
Li liq liqui liquibase
Li liq liqui liquibaseLi liq liqui liquibase
Li liq liqui liquibase
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
 
Gitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQL
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
 
Getting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydbGetting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydb
 
Gitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQLGitora, Version Control for PL/SQL
Gitora, Version Control for PL/SQL
 
Version control for PL/SQL
Version control for PL/SQLVersion control for PL/SQL
Version control for PL/SQL
 
Continuous Delivery Applied
Continuous Delivery AppliedContinuous Delivery Applied
Continuous Delivery Applied
 
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...
Intelligent DevOps - Driving Continuous Delivery by Harnessing the Power of A...
 
Maven and j unit introduction
Maven and j unit introductionMaven and j unit introduction
Maven and j unit introduction
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache sling
 
Database Change Management
Database Change ManagementDatabase Change Management
Database Change Management
 
Last Month in PHP - February 2017
Last Month in PHP - February 2017Last Month in PHP - February 2017
Last Month in PHP - February 2017
 
Mini Training Flyway
Mini Training FlywayMini Training Flyway
Mini Training Flyway
 
Frame switcher library
Frame switcher libraryFrame switcher library
Frame switcher library
 

Similar a Liquibase

Schema migration in agile environmnets
Schema migration in agile environmnetsSchema migration in agile environmnets
Schema migration in agile environmnetsVivek Dhayalan
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
Liquibase Integration with MuleSoft
Liquibase Integration with MuleSoftLiquibase Integration with MuleSoft
Liquibase Integration with MuleSoftNeerajKumar1965
 
Tauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change AutomationTauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change AutomationSQABD
 
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3MysoreMuleSoftMeetup
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBATobias Koprowski
 
SQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database ProjectsSQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database Projectsfloydhilton
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptxLadduAnanu
 
Haj 4308-open jpa, eclipselink, and the migration toolkit
Haj 4308-open jpa, eclipselink, and the migration toolkitHaj 4308-open jpa, eclipselink, and the migration toolkit
Haj 4308-open jpa, eclipselink, and the migration toolkitKevin Sutter
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dbaNaviSoft
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
Evolutionary database design
Evolutionary database designEvolutionary database design
Evolutionary database designSalehein Syed
 
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015Dave Stokes
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)Steve Min
 
MOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMonica Li
 
MOUG17: DB Security; Secure your Data
MOUG17: DB Security; Secure your DataMOUG17: DB Security; Secure your Data
MOUG17: DB Security; Secure your DataMonica Li
 
Liquidating database frustrations with liquibase
Liquidating database frustrations with liquibaseLiquidating database frustrations with liquibase
Liquidating database frustrations with liquibasePaul Churchward
 

Similar a Liquibase (20)

Schema migration in agile environmnets
Schema migration in agile environmnetsSchema migration in agile environmnets
Schema migration in agile environmnets
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Liquibase Integration with MuleSoft
Liquibase Integration with MuleSoftLiquibase Integration with MuleSoft
Liquibase Integration with MuleSoft
 
Tauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change AutomationTauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change Automation
 
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3
MuleSoft integration with Liquibase | Mysore MuleSoft Meetup #3
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
 
SQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database ProjectsSQL in Version Control using SQL Server Database Projects
SQL in Version Control using SQL Server Database Projects
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptx
 
Haj 4308-open jpa, eclipselink, and the migration toolkit
Haj 4308-open jpa, eclipselink, and the migration toolkitHaj 4308-open jpa, eclipselink, and the migration toolkit
Haj 4308-open jpa, eclipselink, and the migration toolkit
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
Evolutionary database design
Evolutionary database designEvolutionary database design
Evolutionary database design
 
Sql server
Sql serverSql server
Sql server
 
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015
MySQL Workbench and Visual Explain -- RMUG Feb 19th 2015
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)
 
MOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical ExamplesMOUG17: SQLT Utility for Tuning - Practical Examples
MOUG17: SQLT Utility for Tuning - Practical Examples
 
MOUG17: DB Security; Secure your Data
MOUG17: DB Security; Secure your DataMOUG17: DB Security; Secure your Data
MOUG17: DB Security; Secure your Data
 
Liquidating database frustrations with liquibase
Liquidating database frustrations with liquibaseLiquidating database frustrations with liquibase
Liquidating database frustrations with liquibase
 

Último

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Último (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Liquibase

  • 2. Software development ● We do a lot of changes during development ● We use version control system for tracking code changes ● However, tracking DB changes is not as easy as tracking code changes
  • 3. Database development There are many different artifacts in database: ● tables ● data, that lives in the tables ● stored procedures ● views ● triggers ● etc (DBMS specific artifacts)
  • 4. What is wrong with DB? ●database has persistent state (that’s why we use it) ●code and database must corresponds ●each developer has local environment ●we change code very often (we agile :) Actually, these issues are Agile specific, in case of waterfall they disappears :)
  • 5. What is solution? Store DB changes in text files (DDL and DML) and apply them manually to DB. A lot of projects use this approach
  • 6. Manual tracking DB changes Possible issues: ● easy to lost sync between code and DB state ● hard to recover from error during development (ex: in case of applying wrong statement to DB) ● often require to re-create DB from scratch during development ● hard to find out state of particular DB environment ● may require to support 2 versions of changes: full and incremental
  • 7. What tools are available? ● Flyway ● Liquibase ● c5-db-migration ● dbdeploy ● mybatis ● MIGRATEdb ● migrate4j ● dbmaintain ● AutoPatch
  • 8. What makes liquibase different? ● DDL abstraction DSL ● Support for different changelog format ○ build-in: XML, YAML, JSON and SQL ○community-managed: groovy and closure ● Over 30 built-in database refactorings ● Rollback database changes feature ● Database diff report ● Extensibility
  • 9. Liquibase major concepts ●Changelog file ●Changeset ●Changes ●Preconditions ●Contexts
  • 10. Liquibase changelog file The root of all Liquibase changes is the databaseChangeLog file. <databaseChangeLog> <changeSet id="1" ...> ... </changeSet> <changeSet id="2" ...> ... </changeSet> </databaseChangeLog>
  • 11. Liquibase changelog file It is possible to break up changelogs into multiple manageable pieces <databaseChangeLog> <include file="src/db/tables.xml"/> <include file="src/db/views.xml"/> <include file="src/db/data.xml"/> ... </databaseChangeLog>
  • 12. Liquibase changeset Changeset is a group of changes Liquibase attempts to execute each changeSet in a transaction that is committed at the end, or rolled back if there is an error.
  • 13. Liquibase changeset <databaseChangeLog> <!-- id, author and current file name must be unique --> <changeSet id="1" author=”sfesenko” > <comment>Sample of changeset</comment> <!-- comment is optional --> <change .. /> <!-- will be explained later --> <!-- rollback is a changeset that must be executed in order to “cancel” current changeset -- > <rollback> <change .. /> </rollback> </changeSet>
  • 14. Liquibase changeset <changeSet id="1" author=”sfesenko” runAlways="true"> <!-- false by default --> … </changeset> <changeSet id="2" author=”sfesenko” runOnChange="true"> <!-- false by default --> … </changeset> <changeSet id="3" author=”sfesenko” failOnError="false"> <!-- true by default --> … </changeset> Useful for views, triggers, stored procedures
  • 15. Liquibase changeset preconditions Both changelog and changeset may have precondition - assertion, that will be evaluated before execution of changeset. Available preconditions: ● check for dbms type ● check for current user name ● check if changeset has been executed ● check if table exists ● check if table has column ● check if view exists ● check if FK constraint exists ● check if index exists ● check if sequence exists ● check if table has primary key (or specified primary key exists) ● arbitrary sql check
  • 16. Liquibase changeset preconditions Sample of precondition usage: <changeSet id="1" author=”sfesenko” > <preConditions onFail="MARK_RAN"> <tableExists tableName="TEST" /> </preConditions> <<dropTable cascadeConstraints="true" tableName=”TEST” /> </changeset>
  • 17. Liquibase changeset context It’s possible to specify for each changeset in what context it should be run. Context value can be specified on liquibase run. <changeSet id="1" author=”sfesenko” context=”clear”> <delete tableName="USERS" /> </changeset>
  • 18. Liquibase change Each changeset contains change which describes required modification of database. It’s possible to use DSL (recommended, dbms independent) or SQL for defining a change.
  • 19. Liquibase change <changeSet id="1" author="sfesenko"> <createTable tableName="CURRENCY"> <column name="CURRENCY" type="varchar(12)" > <constraints primaryKey="true" primaryKeyName="PK_CURRENCY_CURRENCY"/> </column> <column name="ISO" type="java.lang.Integer" /> <column name="DECIMAL_RULES" type="varchar(12)" /> </createTable> <sql> CREATE TABLE CURRENCY ( CURRENCY VARCHAR2(12) NOT NULL, ISO NUMBER(10), DECIMAL_RULES VARCHAR2(12), CONSTRAINT PK_CURRENCY_CURRENCY PRIMARY KEY (CURRENCY) ); </sql> </changeSet>
  • 20. Liquibase changes/refactorings Structural Refactorings ● Add Column ● Rename Column ● Modify Column ● Drop Column ● Alter Sequence ● Create Table ● Rename Table ● Drop Table ● Create View ● Rename View ● Drop View ● Merge Columns ● Create Stored Procedure Data Quality Refactorings ● Add Lookup Table ● Add Not-Null Constraint ● Remove Not-Null Constraint ● Add Unique Constraint ● Drop Unique Constraint ● Create Sequence ● Drop Sequence ● Add Auto-Increment ● Add Default Value ● Drop Default Value Referential Integrity Refactorings ● Add Foreign Key Constraint ● Drop Foreign Key Constraint ● Drop All Foreign Key Constraints ● Add Primary Key Constraint ● Drop Primary Key Constraint Non-Refactoring Transformations ● Insert Data ● Load Data ● Load Update Data ● Update Data ● Delete Data Architectural Refactorings ● Create Index ● Drop Index ● Custom Refactorings Modifying Generated SQL ● Custom SQL ● Custom SQL File ● Custom Refactoring Class ● Execute Shell Command
  • 21. How to run liquibase On Demand Command Line Ant Maven Automated Servlet Listener Spring Listener JEE CDI Listener Java APIs Liquibase can easily be embedded and executed through its Java APIs. Update DB on application start
  • 22. Liquibase command line 1. Create property file liquibase.property with connection parameters: 2. Run liquibase as ./liquibase <command> driver: oracle.jdbc.OracleDriver classpath: ojdbc14-10.2.0.3.0.jar url: jdbc:oracle:thin:@localhost:1521:oracle username: SQ_BANK password: SQ_BANK
  • 23. Liquibase quickstart 1. Generate changelog from existing database Run ./liquibase --changeLogFile=changelog.xml generateChangeLog 1. Dump data to xml file Run ./liquibase --changeLogFile=data.xml --diffTypes=data generateChangeLog Be ready for OutOfMemoryError
  • 24. Liquibase commands ● update ● updateSQL ● validate ● status ● dropAll ● rollbackCount ● generateChangeLog ● diff ● changelogSync ○ changelogSyncSQL ● clearCheckSums
  • 25. Liquibase tips and tricks ● Use one file per changeset (greatly simplified merges) ● Use convention for file names ● Use “run on change” attribute for stored procedures, views, triggers, etc ● Decide early if rollback feature will be used ● Test both incremental and full update ● Do not change “wrong” changeset - just add new one with fix ● Consider possibility of “compressing” changesets when full update became slow
  • 26. When it is good Best case DB Application
  • 27. When it is not so good Worst case DB Application Legacy Application New Application Some other application that we know about Applications that we don’t know about
  • 28. Q & A