the elephant in_the_room_continuous_delivery_for_databases

50
The elephant in the room… …continuous delivery for databases

Upload: red-gate-software

Post on 28-Jul-2015

686 views

Category:

Technology


0 download

TRANSCRIPT

The elephant in the room…

…continuous delivery for databases

I help people deliver databases…

@_AlexYates_

workingwithdevs.com

uk.linkedin.com/in/alexanderyates

[email protected]

Agile Scrum Lean Iterative Continuous Delivery

Monitoring Deployment Integrity Performance

#worksOnMyMachine

A cursor?!You just can’t do that!

#worksOnMyMachine

Hey, you just droppedmy hot-fix!

Focus on the pipeline

Optimize the whole Automate processes Focus on bottlenecks

Odd languages SQL Cubes X-Query

Data persistence Data outlives

applications Data can’t be

replaced

DBA paranoia Frankly…

1 2 3

Databases == Bottleneck

#devops

ProductionDBA

ChiefArchitect

.NET Devteam lead

(Partnersin crime)

SQL Devteam lead

Reliability Safe

deployments Fire prevention

over firefighting

Visibility Visualise

pipeline Better

coordination

DevOps DBA + devs

work together Automation Agility

1 2 3

Goals for project

There’s more than one way to skin a cat!

V1 V2

Migrations based solutions

V1 V2

State based solutions

V1 V2

“There's nothing more reliable than keeping track of exactly the

scripts you intend to run, and running them, without trying to

compare state and guess.” Paul Stovell, built Octopus Deploy

“There's nothing more reliable than keeping track of exactly the

scripts you intend to run, and running them, without trying to

compare state and guess.” Paul Stovell, built Octopus Deploy

“As soon as you have multiple changes on a single aspect of an object, ordering and the ability to detect which change

needs to be made gets very complicated.”

Gert Drapers, built DataDude

Demo: the happy path!

SOURCE CONTROL

CONTINUOUSINTEGRATION

AUTOMATEDDEPLOYMENT

11

2 Table rename Table ‘foo’ is to be renamed ‘bar’

Edit stored procedure Myproc to select col2 from table ‘foo’

(currently it selects only col1)

Task

0124_edit_sproc.sql

ALTER PROCEDURE myprocAS BEGIN SELECT col1, col2 FROM table_foo END

0124_edit_sproc.sql 0125_table_rename.sqlEXEC sp_rename 'table_foo', 'table_bar‘

ALTER PROCEDURE myprocAS BEGIN SELECT col1 FROM table_bar END

ALTER PROCEDURE myprocAS BEGIN SELECT col1, col2 FROM table_foo END

0124_edit_sproc.sql 0125_table_rename.sqlEXEC sp_rename 'table_foo', 'table_bar‘

ALTER PROCEDURE myprocAS BEGIN SELECT col1 FROM table_bar END

ALTER PROCEDURE myprocAS BEGIN SELECT col1, col2 FROM table_foo END !

Conflicts easily missed Changes overwritten

Order matters Last script wins

To review changes Much reading, but very

important to get code right

The problem with migrations

V123

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_foo

!

V123

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_foo

V124

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1, col2 FROM table_foo

V123

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_foo

V124

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1, col2 FROM table_foo

V125

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_bar

V123

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_foo

V124

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1, col2 FROM table_foo

V125

myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_bar

!

REVISION 123 REVISION 124

table_foo.sqlCREATE TABLE table_foo(col1 NVARCHAR(max), col2 NVARCHAR(max)) myproc.sqlCREATE PROCEDURE myprocAS SELECT col1 FROM table_foo

table_bar.sqlCREATE TABLE table_bar(col1 NVARCHAR(max), col2 NVARCHAR(max)) myproc.sqlCREATE PROCEDURE myprocAS SELECT col1, col2 FROM table_bar

Diff script:

DROP TABLE table_foo

CREATE TABLE table_bar(col1 NVARCHAR(max), col2 NVARCHAR(max))

ALTER PROCEDURE myprocAS  SELECT col1, col2 FROM table_bar

The problem with state

Diff script

DROP TABLE table_foo

CREATE TABLE table_bar(col1 NVARCHAR(max), col2 NVARCHAR(max))

ALTER PROCEDURE myprocAS  SELECT col1, col2 FROM table_bar

!

The problem with state

Script

DROP TABLE table_foo

CREATE TABLE table_bar(col1 NVARCHAR(max), col2 NVARCHAR(max))

ALTER PROCEDURE myprocAS SELECT col1, col2 FROM table_bar

Need to understand your tool It should be obvious to you that

your tool won’t work

What is the Plan B / override? Because one day you’ll need it

Test for data loss Automatically (naturally)

The problem with state

One more thing…

State

Easier (less control)

Better for sprocs/functions

Better for large/distributed teams

Better for frequent changes

Better for dependency nightmares

Drift: rolled back

Migrations

More control (harder/needs discipline)

Better for data migrations

Better for small teams

Better for infrequent changes

Better for simple data stores

Drift: ignored

So what is better?

State (+migrations)

SSDT pre/post deploy scripts

Redgate migrations

Migrations (+state)

ReadyRoll ‘deploy changes’

Best of both worlds?

Reliability Safe

deployments Fire prevention

over firefighting

1

Goals for project

Reliability Safe

deployments Fire prevention

over firefighting

Visibility Visualise

pipeline Better

coordination

1 2

Goals for project

Reliability Safe

deployments Fire prevention

over firefighting

Visibility Visualise

pipeline Better

coordination

DevOps DBA + devs

work together Automation Agility

1 2 3

Goals for project

@_AlexYates_

workingwithdevs.com

uk.linkedin.com/in/alexanderyates

[email protected]

Image sourcesAuthor Source Information

Chiltepinster Wikimedia Commons Mocking Bird Argument.jpg – Wikimedia Commons. This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. Source on Wikimedia Commons: “Own work”

Tableatny Wikimedia Commons Athlete at Starting block.jpg – Wikimedia Commons. This file is licensed under the Creative Commons Attribution 2.0 Generic license. Source on Wikimedia Commons: “BXP135671”

Henry Mühlpfordt Flickr CERN Atlas Control Room 2010-07-01 – Flickr. This file is licensed under the Creative Commons Attribution-ShareAlike 2.0 Generic license.

Department for Business, Innovation and Skills

Flickr Toyota’s new Auris – Flickr. This file is licensed under the Creative Commons Attribution-NoDerivs 2.0 Generic license.

Stephen Wolfe Flickr Violinists – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

Akira Hsu Flickr The Micro Four Thirds Logo by Empire Elite Stormtroopers - for the great “Micro Four Thirds Day” – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

Nils Rinaldi Flickr Hippo fight 2/3 – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

My own collection All pictures are either of me, taken by friends/colleagues, or taken by me

All pictures on about me slide, including kitten, and team at Farm Credit Services of America (FCSA). FCSA have allowed me/Redgate to reference the visit in presentations/marketing material etc.

Memegenerator.net Memegenerator.net I don’t always edit database. Content designed to be shared and delivered with credit to memegenerator.net.

Ctrl.Alt.Design ctrla.lt Social Media share icons