SlideShare a Scribd company logo
Database migrations

the missing piece in Java EE

BOF3528
Rikard Thulin
This is a short version of this talk
!
Full length video available at:
http://vimeo.com/105880153
Rikard Thulin
We will discuss how

schema migrations
improves the software engineering life cycle and the
possibilities to improve Java for the future
Roadmap
• Introduction to the topic and why it is so important (7 min)
• Schema Migrations demo (8 min)
• The current situation, the tools of the trade (5 min)
• Future possibilities at hand to solve this problem (5 min)
• Discussion (15 min)
About me
Part 1
!
Introduction to the topic 

and why it is so important
Staging clusterCI
How do we keep 

everything CONSISTENT?
QA
Staging cluster
Prod clusterProd cluster
Dev team
{code}
VCS Build server
How do we keep 

{ code }
CONSISTENT?
artifacts
Repository
push pull
publish
release
QA
promote
DEV/CIStaging
Prod
Dev team
What is the 

problem?
Two entities
Javaone 2014
Javaone 2014
Really?
Is the database EVIL?
artifact manual, script, …
Source Database
HOW
artifact manual, script, …
Source Database
db deltas,

automatic
artifact
Source


{code +
migrations}
VCS Build server
How do we keep 

{ code + database }
CONSISTENT?


artifacts
{code +
migrations}
Repository
push pull
publish
release
QA
promote
Staging
Prod
Dev team
DEV/CI
Shiny Happy People
We get
Schema Migration
DEMO DEMO DEMO DEMO
Schema Migration
DEMO DEMO DEMO DEMO
Migrations are applied automatically 

during deployment
Schema Migration
DEMO DEMO DEMO DEMO
Spring based application
Shiny Happy People
DEMONSTRATION OF
LOCAL DEV PROD
Version 0 Version 0 Version 0
LOCAL DEV PROD
Version 1 Version 0 Version 0
LOCAL DEV PROD
Version 1 Version 1 Version 0
LOCAL DEV PROD
Version 2 Version 1 Version 0
LOCAL DEV PROD
Version 2 Version 3 Version 0
LOCAL DEV PROD
Version 2 Version 3 Version 3
What can we do?
create/drop TABLE

create/drop INDEX

add/remove CONSTRAINT
java REFACTORINGS
STORED PROCEDURES

create/drop VIEWS
insert DATA
!
and more!
What 

is the trick?
When 

is the trick?
Another view
Automatization of:

a sequences of instructions to be executed
given the revision of the source code
Database Change Management

Real Life Tricks
• Possible to use on an existing database
• Quick and simple to implement
• Database copies mix and match
• Wash copies of production database
• DBA approval / review process
• One click release possible
Part 2
!
The current situation 

tools of the trade
Javaone 2014
Tools of the Trade
ActiveRecord Ruby (Ruby)
Entity Framework Migrations (.net)
COMPETITION 

HAS IT
Tools of the Trade
Hibernate & JPA

Schema Generation
Tools of the Trade
FlyWay & Liquibase
Stronger execution order
Supports different DB / environment
Stereotype of being “heavyweight"
Automatic rollback
Convention over configuration

Gaining popularity
Tools of the Trade
FlyWay
Convention over configuration

Get up and running in 5 minutes

Gaining popularity
Tools of the Trade
Liquibase
Stronger execution order
Supports different DB for different environment
Stereotype of being “heavyweight"
Automatic rollback
Tools of the Trade
I [Nathan Voxland] would summarize the differences as:
!
FlyWay is "lower level" with you specifying exactly the SQL
you want ran whereas Liquibase is "higher level" with you
specifying what you want changed and Liquibase
computing the SQL
!
FlyWay manages changes by filename whereas Liquibase
manages changes by order in a file.


Nathan Voxland, Liquibase developer
Tools of the Trade
summary
Schema migration is
•Not solved by Java EE today
•Solved by 3PP
•Already in competitors standards
Part 3
!
Future possibilities 

to solve this problem
The future
my proposal
Add schema migration to
Java EE
Reasons to add Migrations to Java EE
We are behind the competition
Schema migrations is not well know
to the broad developer community
Increased Quality and Productivity

Adding complexity to the platform
Advanced tooling
the future?
the future?
class User {
}
@Migration(id="1", author="duke")
class CreateUserTable {
!
@CreateTable(User.class)
@AddColumn(User.class)
long id;
!
@AddColumn(entity = User.class, size = "255")
String name;
}
the future?
Warning: the following slides are possibilities for the future — not what we have
the future?
@Migration(id="1",
author="duke")
class CreateUserTable {
@AddColumn(User.class)
long id;
…
}
@Entity
class User {
@Id
long id;
…
}
Migration2Code
Generator
Warning: the following slides are possibilities for the future — not what we have
@Entity
class User {
!
@Id
long id;
!
@Column(size="255")
String name;
}
the future?
@Migration(id="2", author="duke")
class AddColumnsToUser {
!
@DropColumn(User.class)
String name;
!
@AddColumn(entity = User.class, size="80")
String firstName;
!
@AddColumn(entity = User.class, size="80")
String lastName;
!
@AddColumn(entity = User.class, size="255")
String email;
}
the future?
Warning: the following slides are possibilities for the future — not what we have
@Entity
class User {
!
@Id
long id;
!
@Column(size="80")
String firstName;
!
@Column(size="80")
String lastName;
!
@Column(size="255")
String email;
}
the future?
Wrap up
YOU! Should use Schema Migration

WE? JCP JSR! "
What? Lets figure it out!"
When? Now. Lets start!
rikard.thulin@squeed.com
Discussion 

and

Q & A
rikard.thulin@squeed.com

More Related Content

PDF
Javantura v4 - Android App Development in 2017 - Matej Vidaković
PDF
Javantura v4 - JVM++ The GraalVM - Martin Toshev
PDF
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
PPTX
SOA with PHP and Symfony
PDF
Real World Java 9
PDF
Micronaut Deep Dive - Devoxx Belgium 2019
PDF
Optimus XPages: An Explosion of Techniques and Best Practices
PPTX
Moving to the Client - JavaFX and HTML5
Javantura v4 - Android App Development in 2017 - Matej Vidaković
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
SOA with PHP and Symfony
Real World Java 9
Micronaut Deep Dive - Devoxx Belgium 2019
Optimus XPages: An Explosion of Techniques and Best Practices
Moving to the Client - JavaFX and HTML5

What's hot (20)

PDF
Introduction to Micronaut - JBCNConf 2019
PDF
Javantura v4 - Angular2 - Ionic2 - from birth to stable versions - Hrvoje Pek...
PPTX
JavaFX and HTML5 - Like Curds and Rice
PPTX
Moving To The Client - JavaFX and HTML5
PPTX
Database deployment: still hard after all these years - Data Saturday #1
PDF
Building RIA Applications with JavaFX
PPT
Jasmine - A BDD test framework for JavaScript
PDF
Micronaut: Evolving Java for the Microservices and Serverless Era
PDF
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
PDF
Java 9 Modularity in Action
PPT
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
PPTX
Moving to the Client - JavaFX and HTML5
PDF
OSGi Community Event 2010 - OSGi and Android
PPTX
A SOA approximation on symfony
PDF
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
PPTX
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
KEY
Scala & Lift (JEEConf 2012)
PPT
Developing modular Java applications
PPTX
Java EE8 - by Kito Mann
PDF
React-js
Introduction to Micronaut - JBCNConf 2019
Javantura v4 - Angular2 - Ionic2 - from birth to stable versions - Hrvoje Pek...
JavaFX and HTML5 - Like Curds and Rice
Moving To The Client - JavaFX and HTML5
Database deployment: still hard after all these years - Data Saturday #1
Building RIA Applications with JavaFX
Jasmine - A BDD test framework for JavaScript
Micronaut: Evolving Java for the Microservices and Serverless Era
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Java 9 Modularity in Action
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
Moving to the Client - JavaFX and HTML5
OSGi Community Event 2010 - OSGi and Android
A SOA approximation on symfony
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Scala & Lift (JEEConf 2012)
Developing modular Java applications
Java EE8 - by Kito Mann
React-js
Ad

Similar to Javaone 2014 (20)

PPTX
Evolutionary database design
PDF
Database Schema Evolution
PDF
Liquibase få kontroll på dina databasförändringar
PPT
Evolutionary Database Design
PPTX
Flyway: The agile database migration framework for Java
PPTX
Webinar: Migrating from RDBMS to MongoDB (June 2015)
PDF
Delivering changes for applications and databases
PDF
Delivering Changes for Applications and Databases
PDF
Migrating from RDBMS to MongoDB
PPTX
Flyway (33rd Degree)
ODP
Liquibase & Flyway @ Baltic DevOps
PDF
Database migrations with Flyway and Liquibase
PPTX
Delhi_Meetup_flyway_Integration.pptx
PDF
Re-Engineering Databases using Meta-Programming Technology
PDF
Are we there Yet?? (The long journey of Migrating from close source to opens...
PPTX
Schema migration in agile environmnets
PPT
Liquibase – a time machine for your data
PPTX
Flyway
PPTX
CHAPTER-4_RELATIONAL-DATABASE.pptx
PPTX
Data Base Design.pptx
Evolutionary database design
Database Schema Evolution
Liquibase få kontroll på dina databasförändringar
Evolutionary Database Design
Flyway: The agile database migration framework for Java
Webinar: Migrating from RDBMS to MongoDB (June 2015)
Delivering changes for applications and databases
Delivering Changes for Applications and Databases
Migrating from RDBMS to MongoDB
Flyway (33rd Degree)
Liquibase & Flyway @ Baltic DevOps
Database migrations with Flyway and Liquibase
Delhi_Meetup_flyway_Integration.pptx
Re-Engineering Databases using Meta-Programming Technology
Are we there Yet?? (The long journey of Migrating from close source to opens...
Schema migration in agile environmnets
Liquibase – a time machine for your data
Flyway
CHAPTER-4_RELATIONAL-DATABASE.pptx
Data Base Design.pptx
Ad

More from Rikard Thulin (6)

PDF
Vi-är-Squeed-1.1
PDF
What a Back-end Java Developer Doesn't Know About the Modern Web Stack-final
PDF
javazone 2014
PDF
Building software using Rich Clients Platforms Rikard Thulin
PDF
Post - JavaOne 2014
PDF
Jigsaw - Javaforum 2015Q4
Vi-är-Squeed-1.1
What a Back-end Java Developer Doesn't Know About the Modern Web Stack-final
javazone 2014
Building software using Rich Clients Platforms Rikard Thulin
Post - JavaOne 2014
Jigsaw - Javaforum 2015Q4

Javaone 2014