SlideShare a Scribd company logo
1 of 126
Download to read offline
Database migrations - the
missing piece in Java EE
Rikard Thulin
3 billion Java developers
lives was ruined on 

August 29, 1997
The survivors of the
deployment called the war
Judgment Day.
They lived only to face a new
nightmare, the war against the
DBA.
Skynet, the computer which
controlled releases, sent 

two engineers back through
time
Their mission: to solve
the problems of
schema migrations…



Opening “quote” from “Terminator 2: Judgment Day”
You willlearnhow to
behappieras you can spend 

more timewriting code!
And we will have alookinto
thefutureand the
possibilities at hand
Roadmap
• Introduction to the topic and why it is so important
• The current situation, the tools of the trade
• Future possibilities at hand to solve this problem
Part 1
Introduction to the topic 

and why it is so important
Finally, 

we where ready to go 

IT WAS RELEASE DAY
Just get the luggage
There might be a small burden
Let the team lead or the smart guy do it!
Or if you are a manager, it translates to the expensive guy
The team goes…
This is your complete team
change recall refactoring applied some marked specified
better run units the tagged along more SQL precondition pain
state both statements contains production Sets applying
database nested things executes identified context leave test
one management Generally apply HOPE change stable
individual ran database just IT generate fails different
changes uniquely per machines change written
productivity log attribute Set change sets development author
files WORKS Contexts describes by descriptive
someone regardless Major else environments column
queries local Each yet either WORK change ANYMORE set
Preconditions DATABASECHANGELOG unexpected control
file !? Concepts stop store execution arbitrarily location auto
commit executed Developers
change recall refactoring applied some marked specified
better run units the tagged along more SQL precondition pain
state both statements contains production Sets applying
database nested things executes identified context leave test
one management Generally apply HOPE change stable
individual ran database just IT generate fails different
changes uniquely per machines change written
productivity log attribute Set change sets development author
files WORKS Contexts describes by descriptive
someone regardless Major else environments column
queries local Each yet either WORK change ANYMORE set
Preconditions DATABASECHANGELOG unexpected control
file !? Concepts stop store execution arbitrarily location auto
commit executed Developers
change recall refactoring applied some marked specified
better run units the tagged along more SQL precondition pain
state both statements contains production Sets applying
database nested things executes identified context leave test
one management Generally apply HOPE change stable
individual ran database just IT generate fails different
changes uniquely per machines change written
productivity log attribute Set change sets development author
files WORKS Contexts describes by descriptive
someone regardless Major else environments column
queries local Each yet either WORK change ANYMORE set
Preconditions DATABASECHANGELOG unexpected control
file !? Concepts stop store execution arbitrarily location auto
commit executed Developers
Finally
we are set to go…






…but…
DBA
Fill in the forms…
You are trapped in the Jar
(aka jar-hell)
It breaks andYou look like this
You gently communicate 

with your fellow co-worker
This was embarrassing
and unprofessional
Time to be a hero!
Engineers likes to be heroes
This has to be a good
thing, right?
You (the smart guy) spend the
weekend
Your boss turns to this
Are you nuts? OVERTIME?!
The obvious solution to
professionally solve the problem
We add pre-release meeting!
change remember refactoring applied some marked
specified better run units the tagged along more SQL
precondition and state both statements contains production
Sets last database nested things executes identified context
leave test one management Generally apply suddenly
change stable individual ran time just a generate fails different
STUFF uniquely per machines change co-worker
productivity log attribute Set change sets development author
files DOES Contexts describes added descriptive NOT
regardless Major a environments column queries local Each
yet either WORK change ANYMORE set Preconditions
DATABASECHANGELOG unexpected control file !? Concepts
stop store execution arbitrarily location auto commit executed
Developers
change remember refactoring applied some marked
specified better run units the tagged along more SQL
precondition and state both statements contains production
Sets last database nested things executes identified context
leave test one management Generally apply suddenly
change stable individual ran time just a generate fails different
STUFF uniquely per machines change co-worker
productivity log attribute Set change sets development author
files DOES Contexts describes added descriptive NOT
regardless Major a environments column queries local Each
yet either WORK change ANYMORE set Preconditions
DATABASECHANGELOG unexpected control file !? Concepts
stop store execution arbitrarily location auto commit executed
Developers
change remember refactoring applied some marked
specified better run units the tagged along more SQL
precondition and state both statements contains production
Sets last database nested things executes identified context
leave test one management Generally apply suddenly
change stable individual ran time just a generate fails different
STUFF uniquely per machines change co-worker
productivity log attribute Set change sets development author
files DOES Contexts describes added descriptive NOT
regardless Major a environments column queries local Each
yet either WORK change ANYMORE set Preconditions
DATABASECHANGELOG unexpected control file !? Concepts
stop store execution arbitrarily location auto commit executed
Developers
$ git pull
change remember refactoring applied some marked
specified better run units the tagged along more SQL
precondition and state both statements contains production
Sets last database nested things executes identified context
leave test one management Generally apply suddenly
change stable individual ran time just a generate fails different
STUFF uniquely per machines change co-worker
productivity log attribute Set change sets development author
files DOES Contexts describes added descriptive NOT
regardless Major a environments column queries local Each
yet either WORK change ANYMORE set Preconditions
DATABASECHANGELOG unexpected control file !? Concepts
stop store execution arbitrarily location auto commit executed
Developers
change remember refactoring applied some marked
specified better run units the tagged along more SQL
precondition and state both statements contains production
Sets last database nested things executes identified context
leave test one management Generally apply suddenly
change stable individual ran time just a generate fails different
STUFF uniquely per machines change co-worker
productivity log attribute Set change sets development author
files DOES Contexts describes added descriptive NOT
regardless Major a environments column queries local Each
yet either WORK change ANYMORE set Preconditions
DATABASECHANGELOG unexpected control file !? Concepts
stop store execution arbitrarily location auto commit executed
Developers
Instead
The aha moment
From
To
The smiling team
Productivity increased
You will learn how to
behappieras you can spend 

more timewriting code!
Sweden
Friendly
neighbor
to
Norway
unlike
Norway
we
do
not
have
a
storage
problem
Proven national gas reserves (cubic meters)
0
2,007,000,000,000
Proven national oil reserves (barrels)
0
5,320,000,000
NO STORAGE PROBLEM
Development
One developer, life is easy!
Development
Obvious we need production
Production
Another
joins
Now each developer can work
Development Production
Time to

bring out the engineer

from the closet
Development ProdCI
for the engineers 

to cooperate

we need Continuos Integration
Time to

really 

bring out the engineer

from the closet
ProdDev CI
someone told the boss that 

things should not only be tested

on end users
QA
Time to

really, really 

bring out the engineer

from the closet
StagingDev CI
Now when we know about quality assurance 

we should stage

our production environment
QA
Prod
More
joins
As we do everything by the book 

things ($) goes well
Staging clusterCI
How do we keep 

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

{ code }
CONSISTENT?
artifacts
Repository
push pull
publish
release
Dev
QA
promote
DevStaging
Prod
How do we keep 

{ code + database }
CONSISTENT?
Two entities
Really?
Is the database EVIL?
artifact manual, script, …
Source Database
the problem is to keep 

them consistent
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
Dev
QA
promote
DevStaging
Prod
Shiny Happy People
You will 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
Schema Migration
DEMO DEMO DEMO DEMO
What you will see
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
alter SQUENCE
STOREDPROCEDURES

create/drop VIEWS
insert DATA
and more!
What 

is the trick?
When 

is the trick?
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
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
Use one of the tools Use one of the tools Use one of the
tools Use one of the tools Use one of the tools Use one
of the tools Use one of the tools Use one of the tools Use
one of the tools Use one of the tools Use one of the tools
Use one of the tools Use one of the tools Use one of the
FlyWay & Liquibase

Use one of the tools Use one of the tools Use one of the
tools Use one of the tools Use one of the tools Use one
of the tools Use one of the tools Use one of the tools Use
one of the tools Use one of the tools Use one of the tools
Use one of the tools Use one of the tools Use one of the
tools Use one of the tools Use one of the tools Use one
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
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?
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?
the future?
@Migration(id="1", author="duke")
class CreateUserTable {
@AddColumn(User.class)
long id;
…
}
@Entity
class User {
@Id
long id;
…
}
Migration2Code
Generator
@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?
@Entity
class User {
@Id
long id;
@Column(size="80")
String firstName;
@Column(size="80")
String lastName;
@Column(size="255")
String email;
}
the future?
The future
my proposal
Add schema migration to
Java EE
The future
my proposal
Who? WE JCP JSR!
What? Lets figure it out!
When? Now. Lets start!
Wrap up
Wrap up
1. Start using one of the tools!
2. We need to figure out if
database migrations is a
candidate to be included in
Java EE
3. Now it the time to take action!
You can be the Hero
Hero wrap up
Q & A
rikard.thulin@squeed.com

More Related Content

What's hot

Prod-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsProd-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsVMware Tanzu
 
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...Simplilearn
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextSvilen Sabev
 
Zero downtime deploys for Rails apps
Zero downtime deploys for Rails appsZero downtime deploys for Rails apps
Zero downtime deploys for Rails appspedrobelo
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdJosh Padnick
 
Drupal Deployment
Drupal DeploymentDrupal Deployment
Drupal DeploymentJeff Eaton
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...Jesse Gallagher
 
Changing application demands: What developers need to know
Changing application demands: What developers need to knowChanging application demands: What developers need to know
Changing application demands: What developers need to knowIndicThreads
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svnAnkur Goyal
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsJohn Ferguson Smart Limited
 
Devops interview-questions-PDF
Devops interview-questions-PDFDevops interview-questions-PDF
Devops interview-questions-PDFMayank Kumar
 
Jenkins Meetup Pune
Jenkins Meetup PuneJenkins Meetup Pune
Jenkins Meetup PuneUmesh Kumhar
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenAlan Parkinson
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondKaushal Dhruw
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 

What's hot (20)

TibcoBW6.0
TibcoBW6.0TibcoBW6.0
TibcoBW6.0
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Prod-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsProd-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized Applications
 
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 2 | Devops Interview Questions And Answers ...
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
 
Implementing your own Google App Engine
Implementing your own Google App Engine Implementing your own Google App Engine
Implementing your own Google App Engine
 
Zero downtime deploys for Rails apps
Zero downtime deploys for Rails appsZero downtime deploys for Rails apps
Zero downtime deploys for Rails apps
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Choosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in ProdChoosing the Right Framework for Running Docker Containers in Prod
Choosing the Right Framework for Running Docker Containers in Prod
 
Drupal Deployment
Drupal DeploymentDrupal Deployment
Drupal Deployment
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Changing application demands: What developers need to know
Changing application demands: What developers need to knowChanging application demands: What developers need to know
Changing application demands: What developers need to know
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yards
 
Devops interview-questions-PDF
Devops interview-questions-PDFDevops interview-questions-PDF
Devops interview-questions-PDF
 
Jenkins Meetup Pune
Jenkins Meetup PuneJenkins Meetup Pune
Jenkins Meetup Pune
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & Beyond
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 

Viewers also liked

Viewers also liked (7)

CHJ NYeC 2013_april11_final
CHJ NYeC 2013_april11_finalCHJ NYeC 2013_april11_final
CHJ NYeC 2013_april11_final
 
E recruitment
E recruitmentE recruitment
E recruitment
 
Post - JavaOne 2014
Post - JavaOne 2014Post - JavaOne 2014
Post - JavaOne 2014
 
Vtcb technologies-esa candidates
Vtcb technologies-esa candidatesVtcb technologies-esa candidates
Vtcb technologies-esa candidates
 
Observations
ObservationsObservations
Observations
 
Javaone 2014
Javaone 2014Javaone 2014
Javaone 2014
 
presentationon_my_development
presentationon_my_developmentpresentationon_my_development
presentationon_my_development
 

Similar to Database migrations - the missing piece in Java EE

Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptxLadduAnanu
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Enkitec
 
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
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
Database Build and Release - SQL In The City - Ernest Hwang
Database Build and Release - SQL In The City - Ernest HwangDatabase Build and Release - SQL In The City - Ernest Hwang
Database Build and Release - SQL In The City - Ernest HwangRed Gate Software
 
SQL Server It Just Runs Faster
SQL Server It Just Runs FasterSQL Server It Just Runs Faster
SQL Server It Just Runs FasterBob Ward
 
Denver SQL Saturday The Next Frontier
Denver SQL Saturday The Next FrontierDenver SQL Saturday The Next Frontier
Denver SQL Saturday The Next FrontierKellyn Pot'Vin-Gorman
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesdrupalindia
 
Source Code Management Slides
Source Code Management SlidesSource Code Management Slides
Source Code Management Slidesdaschuck
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallssam2sung2
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availabilityPeter Gfader
 
Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Red Gate Software
 
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
 
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...LarryZaman
 
DATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backupDATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backupSaewoong Lee
 

Similar to Database migrations - the missing piece in Java EE (20)

Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptx
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
 
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
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
Database Build and Release - SQL In The City - Ernest Hwang
Database Build and Release - SQL In The City - Ernest HwangDatabase Build and Release - SQL In The City - Ernest Hwang
Database Build and Release - SQL In The City - Ernest Hwang
 
SQL Police
SQL PoliceSQL Police
SQL Police
 
SQL Server It Just Runs Faster
SQL Server It Just Runs FasterSQL Server It Just Runs Faster
SQL Server It Just Runs Faster
 
Denver SQL Saturday The Next Frontier
Denver SQL Saturday The Next FrontierDenver SQL Saturday The Next Frontier
Denver SQL Saturday The Next Frontier
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
Source Code Management Slides
Source Code Management SlidesSource Code Management Slides
Source Code Management Slides
 
Copy Data Management for the DBA
Copy Data Management for the DBACopy Data Management for the DBA
Copy Data Management for the DBA
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 
Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control Level up your deployments for SQL Source Control
Level up your deployments for SQL Source Control
 
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
 
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...
Business_Continuity_Planning_with_SQL_Server_HADR_options_TechEd_Bangalore_20...
 
DATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backupDATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backup
 

Database migrations - the missing piece in Java EE

  • 1. Database migrations - the missing piece in Java EE Rikard Thulin
  • 2. 3 billion Java developers lives was ruined on 
 August 29, 1997 The survivors of the deployment called the war Judgment Day.
  • 3. They lived only to face a new nightmare, the war against the DBA. Skynet, the computer which controlled releases, sent 
 two engineers back through time
  • 4. Their mission: to solve the problems of schema migrations…
 
 Opening “quote” from “Terminator 2: Judgment Day”
  • 5. You willlearnhow to behappieras you can spend 
 more timewriting code!
  • 6. And we will have alookinto thefutureand the possibilities at hand
  • 7. Roadmap • Introduction to the topic and why it is so important • The current situation, the tools of the trade • Future possibilities at hand to solve this problem
  • 8. Part 1 Introduction to the topic 
 and why it is so important
  • 9. Finally, 
 we where ready to go 
 IT WAS RELEASE DAY
  • 10. Just get the luggage
  • 11. There might be a small burden
  • 12. Let the team lead or the smart guy do it! Or if you are a manager, it translates to the expensive guy
  • 14. This is your complete team
  • 15. change recall refactoring applied some marked specified better run units the tagged along more SQL precondition pain state both statements contains production Sets applying database nested things executes identified context leave test one management Generally apply HOPE change stable individual ran database just IT generate fails different changes uniquely per machines change written productivity log attribute Set change sets development author files WORKS Contexts describes by descriptive someone regardless Major else environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 16. change recall refactoring applied some marked specified better run units the tagged along more SQL precondition pain state both statements contains production Sets applying database nested things executes identified context leave test one management Generally apply HOPE change stable individual ran database just IT generate fails different changes uniquely per machines change written productivity log attribute Set change sets development author files WORKS Contexts describes by descriptive someone regardless Major else environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 17. change recall refactoring applied some marked specified better run units the tagged along more SQL precondition pain state both statements contains production Sets applying database nested things executes identified context leave test one management Generally apply HOPE change stable individual ran database just IT generate fails different changes uniquely per machines change written productivity log attribute Set change sets development author files WORKS Contexts describes by descriptive someone regardless Major else environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 18. Finally we are set to go… 
 
 
 …but…
  • 19. DBA
  • 20. Fill in the forms…
  • 21. You are trapped in the Jar (aka jar-hell)
  • 22.
  • 23. It breaks andYou look like this
  • 24. You gently communicate 
 with your fellow co-worker
  • 25. This was embarrassing and unprofessional
  • 26.
  • 27. Time to be a hero!
  • 28. Engineers likes to be heroes This has to be a good thing, right?
  • 29. You (the smart guy) spend the weekend
  • 30.
  • 31. Your boss turns to this Are you nuts? OVERTIME?!
  • 32. The obvious solution to professionally solve the problem
  • 33. We add pre-release meeting!
  • 34. change remember refactoring applied some marked specified better run units the tagged along more SQL precondition and state both statements contains production Sets last database nested things executes identified context leave test one management Generally apply suddenly change stable individual ran time just a generate fails different STUFF uniquely per machines change co-worker productivity log attribute Set change sets development author files DOES Contexts describes added descriptive NOT regardless Major a environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 35. change remember refactoring applied some marked specified better run units the tagged along more SQL precondition and state both statements contains production Sets last database nested things executes identified context leave test one management Generally apply suddenly change stable individual ran time just a generate fails different STUFF uniquely per machines change co-worker productivity log attribute Set change sets development author files DOES Contexts describes added descriptive NOT regardless Major a environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 36. change remember refactoring applied some marked specified better run units the tagged along more SQL precondition and state both statements contains production Sets last database nested things executes identified context leave test one management Generally apply suddenly change stable individual ran time just a generate fails different STUFF uniquely per machines change co-worker productivity log attribute Set change sets development author files DOES Contexts describes added descriptive NOT regardless Major a environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers $ git pull
  • 37. change remember refactoring applied some marked specified better run units the tagged along more SQL precondition and state both statements contains production Sets last database nested things executes identified context leave test one management Generally apply suddenly change stable individual ran time just a generate fails different STUFF uniquely per machines change co-worker productivity log attribute Set change sets development author files DOES Contexts describes added descriptive NOT regardless Major a environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 38. change remember refactoring applied some marked specified better run units the tagged along more SQL precondition and state both statements contains production Sets last database nested things executes identified context leave test one management Generally apply suddenly change stable individual ran time just a generate fails different STUFF uniquely per machines change co-worker productivity log attribute Set change sets development author files DOES Contexts describes added descriptive NOT regardless Major a environments column queries local Each yet either WORK change ANYMORE set Preconditions DATABASECHANGELOG unexpected control file !? Concepts stop store execution arbitrarily location auto commit executed Developers
  • 40.
  • 42. From
  • 43. To
  • 46. You will learn how to behappieras you can spend 
 more timewriting code!
  • 50. to
  • 54. we
  • 55. do
  • 56. not
  • 57. have
  • 58. a
  • 61. Proven national gas reserves (cubic meters) 0 2,007,000,000,000 Proven national oil reserves (barrels) 0 5,320,000,000 NO STORAGE PROBLEM
  • 62.
  • 64. Development Obvious we need production Production
  • 66. Now each developer can work Development Production
  • 67. Time to
 bring out the engineer
 from the closet
  • 68. Development ProdCI for the engineers 
 to cooperate
 we need Continuos Integration
  • 69. Time to
 really 
 bring out the engineer
 from the closet
  • 70. ProdDev CI someone told the boss that 
 things should not only be tested
 on end users QA
  • 71. Time to
 really, really 
 bring out the engineer
 from the closet
  • 72. StagingDev CI Now when we know about quality assurance 
 we should stage
 our production environment QA Prod
  • 73. More joins As we do everything by the book 
 things ($) goes well
  • 74. Staging clusterCI How do we keep 
 everything CONSISTENT? QA Staging cluster Prod clusterProd cluster Dev
  • 75. {code} VCS Build server How do we keep 
 { code } CONSISTENT? artifacts Repository push pull publish release Dev QA promote DevStaging Prod
  • 76. How do we keep 
 { code + database } CONSISTENT?
  • 78.
  • 79.
  • 81. artifact manual, script, … Source Database
  • 82. the problem is to keep 
 them consistent
  • 83. HOW
  • 84. artifact manual, script, … Source Database db deltas,
 automatic
  • 86. 
 {code + migrations} VCS Build server How do we keep 
 { code + database } CONSISTENT? 
 artifacts {code + migrations} Repository push pull publish release Dev QA promote DevStaging Prod
  • 89. Schema Migration DEMO DEMO DEMO DEMO Migrations are applied automatically 
 during deployment
  • 90. Schema Migration DEMO DEMO DEMO DEMO Spring based application
  • 91. Schema Migration DEMO DEMO DEMO DEMO What you will see
  • 93. LOCAL DEV PROD Version 0 Version 0 Version 0
  • 94. LOCAL DEV PROD Version 1 Version 0 Version 0
  • 95. LOCAL DEV PROD Version 1 Version 1 Version 0
  • 96. LOCAL DEV PROD Version 2 Version 1 Version 0
  • 97. LOCAL DEV PROD Version 2 Version 3 Version 0
  • 98. LOCAL DEV PROD Version 2 Version 3 Version 3
  • 99. What can we do? create/drop TABLE
 create/drop INDEX
 add/remove CONSTRAINT alter SQUENCE STOREDPROCEDURES
 create/drop VIEWS insert DATA and more!
  • 100. What 
 is the trick?
  • 101. When 
 is the trick?
  • 102. 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
  • 103. Part 2 The current situation 
 tools of the trade
  • 104.
  • 105. Tools of the Trade ActiveRecord Ruby (Ruby) Entity Framework Migrations (.net) COMPETITION 
 HAS IT
  • 106. Tools of the Trade Hibernate & JPA
 Schema Generation
  • 107. Tools of the Trade FlyWay & Liquibase Stronger execution order Supports different DB / environment Stereotype of being “heavyweight" Automatic rollback Convention over configuration
 Gaining popularity
  • 108. Tools of the Trade FlyWay Convention over configuration
 Get up and running in 5 minutes
 Gaining popularity
  • 109. Tools of the Trade Liquibase Stronger execution order Supports different DB for different environment Stereotype of being “heavyweight" Automatic rollback
  • 110. Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the FlyWay & Liquibase
 Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one of the tools Use one
  • 111. Tools of the Trade summary Schema migration is •Not solved by Java EE today •Solved by 3PP •Already in competitors standards
  • 112. Part 3 Future possibilities 
 to solve this problem
  • 113. 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
  • 116. @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?
  • 117. the future? @Migration(id="1", author="duke") class CreateUserTable { @AddColumn(User.class) long id; … } @Entity class User { @Id long id; … } Migration2Code Generator
  • 118. @Entity class User { @Id long id; @Column(size="255") String name; } the future?
  • 119. @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?
  • 120. @Entity class User { @Id long id; @Column(size="80") String firstName; @Column(size="80") String lastName; @Column(size="255") String email; } the future?
  • 121. The future my proposal Add schema migration to Java EE
  • 122. The future my proposal Who? WE JCP JSR! What? Lets figure it out! When? Now. Lets start!
  • 124. Wrap up 1. Start using one of the tools! 2. We need to figure out if database migrations is a candidate to be included in Java EE 3. Now it the time to take action!
  • 125. You can be the Hero Hero wrap up