SlideShare una empresa de Scribd logo
1 de 31
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

Más contenido relacionado

La actualidad más candente

Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with LiquibaseIllia Seleznov
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developersIllia Seleznov
 
Introduction To Liquibase
Introduction To Liquibase Introduction To Liquibase
Introduction To Liquibase Knoldus Inc.
 
Database Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDatabase Migrations with Gradle and Liquibase
Database Migrations with Gradle and LiquibaseDan Stine
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsHolly Schinsky
 
Azure Data Factory
Azure Data FactoryAzure Data Factory
Azure Data FactoryHARIHARAN R
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudEberhard Wolff
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxNeoClova
 
Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction Kanika Gera
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data AccessDzmitry Naskou
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
BigQuery implementation
BigQuery implementationBigQuery implementation
BigQuery implementationSimon Su
 
Azure data factory
Azure data factoryAzure data factory
Azure data factoryDavid Giard
 

La actualidad más candente (20)

Successful DB migrations with Liquibase
 Successful DB migrations with Liquibase Successful DB migrations with Liquibase
Successful DB migrations with Liquibase
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Introduction To Liquibase
Introduction To Liquibase Introduction To Liquibase
Introduction To Liquibase
 
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
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Azure datafactory
Azure datafactoryAzure datafactory
Azure datafactory
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
Azure Data Factory
Azure Data FactoryAzure Data Factory
Azure Data Factory
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring Cloud
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
BigQuery implementation
BigQuery implementationBigQuery implementation
BigQuery implementation
 
Azure data factory
Azure data factoryAzure data factory
Azure data factory
 

Destacado

Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With LiquibaseIASA
 
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 migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseLars Östling
 
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
 
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 2017Eric 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 succeedAxel 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 wayAndi 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 flywaydbGirish Bapat
 
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
 

Destacado (16)

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
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and Liquibase
 
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 a 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 controlMarcin Przepiórowski
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
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
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005rainynovember12
 
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 MergeClay 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 SSISMark 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 PerspectiveJohn Calvert
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersAdam 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 ProfilingAbouzar Noori
 
Sql Server 2005 Business Inteligence
Sql Server 2005 Business InteligenceSql Server 2005 Business Inteligence
Sql Server 2005 Business Inteligenceabercius24
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 

Similar a 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
 

Último

TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 

Último (20)

TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 

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

Notas del editor

  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