SlideShare a Scribd company logo
source control for your DB
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
v1.0.0
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
v1.2.1
v1.0.0
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
v1.2.1
v1.6.0
v1.0.0
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
v1.2.1
v1.6.0
v2.0.1
v1.0.0
why
Data Base migration:
Data base structure:
- Tables, constrains, indexes;
Data base data:
- Initial data like list of post codes,
statuses for order, etc.
Data base logic:
- stored procedures, triggers, functions
v1.2.1
v1.6.0
v2.0.1
v1.0.0
What
Liquibase :
•Apache license
•Started in 2006 (active)
What
Liquibase :
•Database migration for Java;
•Can be used as
•Ant, Maven or Gradle plugin,
•as CLI tool;
• as part of the system :
•Servlet Listener
•Spring Listener
•JEE CDI Listener
how it works
•Supports multiple database types:
MySQL, PostgreSQL, Oracle, MsSql,
Sybase_Enterprise, Sybase_Anywhere , DB2,
Apache_Derby, HSQL, H2, Informix, Firebird,
SQLite
how it works
Changes are grouped into changesets:
• Change(s) that should be applied
atomically
Changesets are grouped into
changelogs:
•Files managed in version control
how it works
Supports XML, YAML, JSON (DSL for database changes)
and SQL formats:
•Create Table, Add PK, Add FK, Add
Column, Add Index, …
•Drop Table, Drop PK, Drop FK, Drop
Column, Drop Index, …
•Insert, Update, Delete, …
how it works
•Changeslog (XML):
<databaseChangeLog xmlns=…>
<changeSet author="liquibase-docs“
id="addColumn-example">
<addColumn catalogName="cat“
schemaName="public"
tableName="person">
<column name="address"
type="varchar(255)"/> </addColumn>
</changeSet>
<changeSet> ….</changeset>
<changeSet> ….</changeset>
</databaseChangeLog>
how it works
•Changeslog (YAML):
databaseChangeLog:
changeSet:
id: addColumn-example
author: liquibase-docs
changes:
- addColumn:
catalogName: cat
columns:
- column:
name: address
type: varchar(255)
schemaName: public
tableName: person
how it works
•Changeslog (JSON){
databaseChangeLog: [
"changeSet": {
"id": "addColumn-example",
"author": "liquibase-docs",
"changes": [
{
"addColumn": {
"catalogName": "cat",
"columns": [
{
"column": {
"name": "address",
"type": "varchar(255)“
}
}]
,
"schemaName": "public",
"tableName": "person"
}
}]
}
how it works
- Changesets uniquely identified by [Author, ID, File path]
- Liquibase tracks changeset execution in a special table
- Lock table to prevent concurrent Liquibase invocations
- Modified changesets are detected via checksums
how it works
DatabaseChangelogLock:
DatabaseChangelog:
how it works
CLI commands:
update [Count, Tag]
rollback [Count, Data, Tag]
generateChangeLog --diffTypes=tables, views,
columns, indexes, foreignkeys, primarykeys,
uniqueconstraints, data
diff --referenceUrl=<value>
status --verbose
updateSQL ...
let us try it
DDLv1
DDL
v2
v1
Init data,
new column
(source)
let us try it
how it works
DDL
v2
v3
v1
Init data,
new column
(source)
Move values in
separate table
let us try it
let us try it
DDL
v2
v3
v1
Init data,
new column
(source)
Move values in
separate table
how it works
DEMO
how it works
Spring config (embedded in your
application):
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
<property name="dataSource" ref="myDataSource" />
<property name="changeLog" value="classpath:db-changelog.xml" />
<!-- contexts specifies the runtime contexts to use. -->
<property name="contexts" value="test, production" />
</bean>
how it works
Spring Boot config (embedded in your
application ):
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
none
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-liquibase
how it works
•Also:
<changeSet id="4" dbms="oracle">
<sqlFile path="5.sql"/>
</changeSet>
<changeSet id="5" context="test">
<sqlFile path="5.sql"/>
</changeSet>
<changeSet id="6" failOnError="false">
<sqlFile path="6.sql"/>
</changeSet>
how it works
•Also:
<preConditions>
<dbms type="oracle" />
<runningAs username="SYSTEM" />
</preConditions>
<changeSet id="1" author="bob">
<preConditions onFail="WARN">
<sqlCheck expectedResult="0">
select count(*) from oldtable
</sqlCheck>
</preConditions>
<comment>Comments should go after preCondition. If they are before then
liquibase usually gives error.</comment>
<dropTable tableName="oldtable"/>
</changeSet>
recommendations
• it is better to have each change in separate changes ;
• Document changesets with <comment> tag;
• Folders structure should reflect migration structure
com
example
db
changelog
db.changelog-master.xml
db.changelog-1.0.xml
db.changelog-1.1.xml
db.changelog-2.0.xml
peculiarities
•if you do roll back, Liquibase deletes the log line about the update from
databasechangelog table, and after that Liguibase does not know any more
that this change was applied and reverted;
•all changes are applied sequentially, so we can not apply/rollback
separate mediate changes;
•no straightforward way of customizing warn/error messages;
peculiarities
•Each change set has an “id” and “author” attribute which, along with the directory
and file name of the the change log file, uniquely identifies it. Dark side of it is that
running the same change set using relative and absolute path will be considered
as different changesets!
For example we have file /home/user/changelog-0.1.0.xml
First we execute:
$ liquibase --changeLogFile=/home/user/changelog-0.1.0.xml
and then if we try to execute
$ liquibase --changeLogFile=changelog-0.1.0.xml
The end
Thank you for attention
Q & A
r.uholnikov@levi9.com

More Related Content

What's hot

Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a Service
Andrew Solomon
 
Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with Liquibase
Illia Seleznov
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and Liquibase
Lars Östling
 
使用 Liquibase 發展資料庫結構
使用 Liquibase 發展資料庫結構使用 Liquibase 發展資料庫結構
使用 Liquibase 發展資料庫結構
Steven Wang
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
Illia Seleznov
 
Flyway
FlywayFlyway
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Database Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDatabase Migrations with Gradle and Liquibase
Database Migrations with Gradle and Liquibase
Dan Stine
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
Sébastien Saunier
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
KMS Technology
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsJames Bayer
 
Git
GitGit
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
git and github
git and githubgit and github
git and github
Darren Oakley
 
Flywaydb
FlywaydbFlywaydb
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
Sven Peters
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
Craig Smith
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
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
Joris Kuipers
 

What's hot (20)

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
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and Liquibase
 
使用 Liquibase 發展資料庫結構
使用 Liquibase 發展資料庫結構使用 Liquibase 發展資料庫結構
使用 Liquibase 發展資料庫結構
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 
Flyway
FlywayFlyway
Flyway
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Database Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDatabase Migrations with Gradle and Liquibase
Database Migrations with Gradle and Liquibase
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic Concepts
 
Git
GitGit
Git
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
git and github
git and githubgit and github
git and github
 
Flywaydb
FlywaydbFlywaydb
Flywaydb
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
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
 

Viewers also liked

Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
IASA
 
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
Neev 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 Datenbankmigrationstools
Stephan Kaps
 
GWT widget development
GWT widget developmentGWT widget development
GWT widget development
pgt technology scouting GmbH
 
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
Squeed
 
Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)
Axel Fontaine
 
Last Month in PHP - February 2017
Last Month in PHP - February 2017Last Month in PHP - February 2017
Last Month in PHP - February 2017
Eric Poe
 
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeedContinuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Axel Fontaine
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaAxel Fontaine
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
Axel Fontaine
 
Refactoring domain driven design way
Refactoring domain driven design wayRefactoring domain driven design way
Refactoring domain driven design way
Andi Pangeran
 
Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!
Return on Intelligence
 
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
Girish Bapat
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
Jonathan Holloway
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
Tim Berglund
 

Viewers also liked (15)

Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
 
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
 
GWT widget development
GWT widget developmentGWT widget development
GWT widget development
 
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
 
Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)
 
Last Month in PHP - February 2017
Last Month in PHP - February 2017Last Month in PHP - February 2017
Last Month in PHP - February 2017
 
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeedContinuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for Java
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
 
Refactoring domain driven design way
Refactoring domain driven design wayRefactoring domain driven design way
Refactoring domain driven design way
 
Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!Unit Tests? It is Very Simple and Easy!
Unit Tests? It is Very Simple and Easy!
 
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
 
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
 

Similar to Liquibase migration for data bases

SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
SE2016 Java Roman Ugolnikov "Migration and source control for your DB"SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
Inhacking
 
Roman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your dbRoman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your db
Аліна Шепшелей
 
Take your database source code and data under control
Take your database source code and data under controlTake your database source code and data under control
Take your database source code and data under control
Marcin Przepiórowski
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
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
Teamstudio
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
rainynovember12
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAmin Uddin
 
ORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGSanthosh Sap
 
Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data Merge
Clay Helberg
 
Microsoft Data Integration Pipelines: Azure Data Factory and SSIS
Microsoft Data Integration Pipelines: Azure Data Factory and SSISMicrosoft Data Integration Pipelines: Azure Data Factory and SSIS
Microsoft Data Integration Pipelines: Azure Data Factory and SSIS
Mark Kromer
 
Migrating to SharePoint 2013 - Business and Technical Perspective
Migrating to SharePoint 2013 - Business and Technical PerspectiveMigrating to SharePoint 2013 - Business and Technical Perspective
Migrating to SharePoint 2013 - Business and Technical Perspective
John Calvert
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
Mike Willbanks
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
Adam Hutson
 
Lifecycle Management of SOA Artifacts for WSO2 Products
Lifecycle Management of SOA Artifacts for WSO2 ProductsLifecycle Management of SOA Artifacts for WSO2 Products
Lifecycle Management of SOA Artifacts for WSO2 ProductsWSO2
 
SQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and ProfilingSQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and Profiling
Abouzar Noori
 
Sql Server 2005 Business Inteligence
Sql Server 2005 Business InteligenceSql Server 2005 Business Inteligence
Sql Server 2005 Business Inteligence
abercius24
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
Andrei Solntsev
 

Similar to Liquibase migration for data bases (20)

SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
SE2016 Java Roman Ugolnikov "Migration and source control for your DB"SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
SE2016 Java Roman Ugolnikov "Migration and source control for your DB"
 
Roman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your dbRoman Ugolnikov Migrationа and sourcecontrol for your db
Roman Ugolnikov Migrationа and sourcecontrol for your db
 
Take your database source code and data under control
Take your database source code and data under controlTake your database source code and data under control
Take your database source code and data under control
 
ETL
ETL ETL
ETL
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
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
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
 
ORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAININGORACLE APPS DBA ONLINE TRAINING
ORACLE APPS DBA ONLINE TRAINING
 
Dynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data MergeDynamic Publishing with Arbortext Data Merge
Dynamic Publishing with Arbortext Data Merge
 
Microsoft Data Integration Pipelines: Azure Data Factory and SSIS
Microsoft Data Integration Pipelines: Azure Data Factory and SSISMicrosoft Data Integration Pipelines: Azure Data Factory and SSIS
Microsoft Data Integration Pipelines: Azure Data Factory and SSIS
 
Jsf2.0 -4
Jsf2.0 -4Jsf2.0 -4
Jsf2.0 -4
 
Migrating to SharePoint 2013 - Business and Technical Perspective
Migrating to SharePoint 2013 - Business and Technical PerspectiveMigrating to SharePoint 2013 - Business and Technical Perspective
Migrating to SharePoint 2013 - Business and Technical Perspective
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
 
Lifecycle Management of SOA Artifacts for WSO2 Products
Lifecycle Management of SOA Artifacts for WSO2 ProductsLifecycle Management of SOA Artifacts for WSO2 Products
Lifecycle Management of SOA Artifacts for WSO2 Products
 
SQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and ProfilingSQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and Profiling
 
Sql Server 2005 Business Inteligence
Sql Server 2005 Business InteligenceSql Server 2005 Business Inteligence
Sql Server 2005 Business Inteligence
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 

Recently uploaded

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 

Recently uploaded (20)

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 

Liquibase migration for data bases

  • 2. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions
  • 3. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions v1.0.0
  • 4. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions v1.2.1 v1.0.0
  • 5. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions v1.2.1 v1.6.0 v1.0.0
  • 6. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions v1.2.1 v1.6.0 v2.0.1 v1.0.0
  • 7. why Data Base migration: Data base structure: - Tables, constrains, indexes; Data base data: - Initial data like list of post codes, statuses for order, etc. Data base logic: - stored procedures, triggers, functions v1.2.1 v1.6.0 v2.0.1 v1.0.0
  • 9. What Liquibase : •Database migration for Java; •Can be used as •Ant, Maven or Gradle plugin, •as CLI tool; • as part of the system : •Servlet Listener •Spring Listener •JEE CDI Listener
  • 10. how it works •Supports multiple database types: MySQL, PostgreSQL, Oracle, MsSql, Sybase_Enterprise, Sybase_Anywhere , DB2, Apache_Derby, HSQL, H2, Informix, Firebird, SQLite
  • 11. how it works Changes are grouped into changesets: • Change(s) that should be applied atomically Changesets are grouped into changelogs: •Files managed in version control
  • 12. how it works Supports XML, YAML, JSON (DSL for database changes) and SQL formats: •Create Table, Add PK, Add FK, Add Column, Add Index, … •Drop Table, Drop PK, Drop FK, Drop Column, Drop Index, … •Insert, Update, Delete, …
  • 13. how it works •Changeslog (XML): <databaseChangeLog xmlns=…> <changeSet author="liquibase-docs“ id="addColumn-example"> <addColumn catalogName="cat“ schemaName="public" tableName="person"> <column name="address" type="varchar(255)"/> </addColumn> </changeSet> <changeSet> ….</changeset> <changeSet> ….</changeset> </databaseChangeLog>
  • 14. how it works •Changeslog (YAML): databaseChangeLog: changeSet: id: addColumn-example author: liquibase-docs changes: - addColumn: catalogName: cat columns: - column: name: address type: varchar(255) schemaName: public tableName: person
  • 15. how it works •Changeslog (JSON){ databaseChangeLog: [ "changeSet": { "id": "addColumn-example", "author": "liquibase-docs", "changes": [ { "addColumn": { "catalogName": "cat", "columns": [ { "column": { "name": "address", "type": "varchar(255)“ } }] , "schemaName": "public", "tableName": "person" } }] }
  • 16. how it works - Changesets uniquely identified by [Author, ID, File path] - Liquibase tracks changeset execution in a special table - Lock table to prevent concurrent Liquibase invocations - Modified changesets are detected via checksums
  • 18. how it works CLI commands: update [Count, Tag] rollback [Count, Data, Tag] generateChangeLog --diffTypes=tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data diff --referenceUrl=<value> status --verbose updateSQL ...
  • 19. let us try it DDLv1
  • 21. how it works DDL v2 v3 v1 Init data, new column (source) Move values in separate table let us try it
  • 22. let us try it DDL v2 v3 v1 Init data, new column (source) Move values in separate table
  • 24. how it works Spring config (embedded in your application): <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>${liquibase.version}</version> </dependency> <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase"> <property name="dataSource" ref="myDataSource" /> <property name="changeLog" value="classpath:db-changelog.xml" /> <!-- contexts specifies the runtime contexts to use. --> <property name="contexts" value="test, production" /> </bean>
  • 25. how it works Spring Boot config (embedded in your application ): <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>${liquibase.version}</version> </dependency> none https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-liquibase
  • 26. how it works •Also: <changeSet id="4" dbms="oracle"> <sqlFile path="5.sql"/> </changeSet> <changeSet id="5" context="test"> <sqlFile path="5.sql"/> </changeSet> <changeSet id="6" failOnError="false"> <sqlFile path="6.sql"/> </changeSet>
  • 27. how it works •Also: <preConditions> <dbms type="oracle" /> <runningAs username="SYSTEM" /> </preConditions> <changeSet id="1" author="bob"> <preConditions onFail="WARN"> <sqlCheck expectedResult="0"> select count(*) from oldtable </sqlCheck> </preConditions> <comment>Comments should go after preCondition. If they are before then liquibase usually gives error.</comment> <dropTable tableName="oldtable"/> </changeSet>
  • 28. recommendations • it is better to have each change in separate changes ; • Document changesets with <comment> tag; • Folders structure should reflect migration structure com example db changelog db.changelog-master.xml db.changelog-1.0.xml db.changelog-1.1.xml db.changelog-2.0.xml
  • 29. peculiarities •if you do roll back, Liquibase deletes the log line about the update from databasechangelog table, and after that Liguibase does not know any more that this change was applied and reverted; •all changes are applied sequentially, so we can not apply/rollback separate mediate changes; •no straightforward way of customizing warn/error messages;
  • 30. peculiarities •Each change set has an “id” and “author” attribute which, along with the directory and file name of the the change log file, uniquely identifies it. Dark side of it is that running the same change set using relative and absolute path will be considered as different changesets! For example we have file /home/user/changelog-0.1.0.xml First we execute: $ liquibase --changeLogFile=/home/user/changelog-0.1.0.xml and then if we try to execute $ liquibase --changeLogFile=changelog-0.1.0.xml
  • 31. The end Thank you for attention Q & A r.uholnikov@levi9.com

Editor's Notes

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31