31
Automate Your Database Deployments Continuous delivery for databases Grant Fritchey Red Gate Software

Automate Database Deployment - SQL In The City Workshop

Embed Size (px)

DESCRIPTION

Presentation from Grant Fritchey on how to automate database deployments. Presentation from SQL In The City Workshop

Citation preview

Page 1: Automate Database Deployment - SQL In The City Workshop

Automate Your Database DeploymentsContinuous delivery for databases

Grant FritcheyRed Gate Software

Page 2: Automate Database Deployment - SQL In The City Workshop

Get in touch

scarydba.com

[email protected]

@gfritchey

Grant Fritchey

Page 3: Automate Database Deployment - SQL In The City Workshop

Get in touch

[email protected]

@way0utwest

Steve Jones

Page 4: Automate Database Deployment - SQL In The City Workshop

Development

Continuous integration

Build Test

Publish Sync

ALTERTABLEfoo…

Deployment script

Release management

Artifact repository

Production

Trigger

Review, Backup & deploy

Source control

QA / Test / Pre-production

Continuous delivery for databases

Database release pipeline

Continuous IntegrationDevelopment ProductionTesting

OperationsDatabase development

and change management

Page 5: Automate Database Deployment - SQL In The City Workshop

Development

Continuous integration

Build Test

Publish Sync

ALTERTABLEfoo…

Deployment script

Release management

Artifact repository

Production

Trigger

Review, Backup & deploy

Source control

QA / Test / Pre-production

Continuous delivery for databases

In this presentation

Database release pipelineContinuous IntegrationDevelopment ProductionTesting

Page 6: Automate Database Deployment - SQL In The City Workshop

Goals

• Understand the patterns and practices for

automating database deployments.

• Learn about the advantages continuous integration

brings to a release pipeline.

• Understand the challenges databases present for

continuous delivery.

Page 7: Automate Database Deployment - SQL In The City Workshop

Continuous delivery – what it is and isn’t

Common misconception:

Continuous delivery = Continuous deployment

But in fact:Continuous delivery means making sure your database changes are always production-ready.

Page 8: Automate Database Deployment - SQL In The City Workshop

Recap: Continuous Delivery

Development Test Production

Continuous integration

Continuous deployment

Continuous delivery

Release pipeline

Approvalgate

Page 9: Automate Database Deployment - SQL In The City Workshop

Four key stages of the deployment pipeline

SOURCECONTROL

CONTINUOUS INTEGRATION

AUTOMATED TESTING

AUTOMATED DEPLOYMENT

Page 10: Automate Database Deployment - SQL In The City Workshop

Get your database under control

• Use version control for all code (including tests)

• Commit early, commit often• Use tools

o If it’s hard, people don’t do it• Train people• Build often

SOURCECONTROL

Page 11: Automate Database Deployment - SQL In The City Workshop

Continuous Integration

• Requires• Code repository• Build automation

• Delivers• Functional testing• Delivery testing• Artifact generation

CONTINUOUS INTEGRATION:

FUNDAMENTALS

Page 12: Automate Database Deployment - SQL In The City Workshop

Database Deployments in CI

• Complete deployment• Fast• Partial build validation• Functional validation• No artifact

• Incremental deployment• Longer• Harder• Complete build validation• Generates artifact

CONTINUOUS INTEGRATION:

FUNDAMENTALS

Page 13: Automate Database Deployment - SQL In The City Workshop

Demo

Page 14: Automate Database Deployment - SQL In The City Workshop

Development

Continuous integration

Build Test

Publish Sync

ALTERTABLEfoo…

Deployment script

Release management

Artifact repository

Production

Trigger

Review, Backup & deploy

Source control

QA / Test / Pre-production

Continuous delivery for databases

Focus here

Build out your release strategyContinuous IntegrationDevelopment ProductionTesting

Page 15: Automate Database Deployment - SQL In The City Workshop

Automation

Page 16: Automate Database Deployment - SQL In The City Workshop

Automation

Deploymentpackage

Page 17: Automate Database Deployment - SQL In The City Workshop

deployment package1

2

3Back to

Development

FAIL

Page 18: Automate Database Deployment - SQL In The City Workshop

Development

Continuous integration

Build Test

Publish Sync

ALTERTABLEfoo…

Deployment script

Release management

Artifact repository

Production

Trigger

Review, Backup & deploy

Source control

QA / Test / Pre-production

Continuous delivery for databases

Repository might be separate piece of software or part of release management software

Continuous IntegrationDevelopment ProductionTesting

OperationsDatabase development

and change management

Page 19: Automate Database Deployment - SQL In The City Workshop

Demo

Page 20: Automate Database Deployment - SQL In The City Workshop

Pre-production is a dry-run

• Staging matches production• As close as possible• Can use diff tool • Or backup and restore AUTOMATED

DEPLOYMENT

Page 21: Automate Database Deployment - SQL In The City Workshop

Development

Continuous integration

Build Test

Publish Sync

ALTERTABLEfoo…

Deployment script

Release management

Artifact repository

Production

Trigger

Review, Backup & deploy

Source control

QA / Test / Pre-production

Continuous delivery for databases

Continuous IntegrationDevelopment ProductionTesting

OperationsDatabase development

and change management

Page 22: Automate Database Deployment - SQL In The City Workshop

Wait…

Page 23: Automate Database Deployment - SQL In The City Workshop

Check for database drift

• Last-minute hotfix• Manual emergency fixes• Unknown changes

AUTOMATED DEPLOYMENT

Page 24: Automate Database Deployment - SQL In The City Workshop

Ready to go now?…

Page 25: Automate Database Deployment - SQL In The City Workshop

Plan for things to go wrong

…you need a rollback and recovery strategy

AUTOMATED DEPLOYMENT

Page 26: Automate Database Deployment - SQL In The City Workshop

Protection

• Backups• Snapshots• Rollback scripts• A/B or blue/green deployments• Roll forward scripts

AUTOMATED DEPLOYMENT

Page 27: Automate Database Deployment - SQL In The City Workshop

Demo

Page 28: Automate Database Deployment - SQL In The City Workshop

Recap: Continuous Delivery

Development Test Production

Continuous integration

Continuous deployment

Continuous delivery

Release pipeline

Approvalgate

Page 29: Automate Database Deployment - SQL In The City Workshop

Documentation and resources

• Continuous Delivery by Jez Humble and David Farley (Addison Wesley)• The Phoenix Project: A Novel About IT, DevOps, and Helping Your Business Win by Gene Kim,

Kevin Behr and George Spafford (IT Revolution Press)• The Goal: A Process of Ongoing Improvement by Eliyahu M. Goldratt and Jeff Cox (Gower

Publishing Ltd.)• Agile Organization by the agile admin (theagileadmin.com)

Further resources:• Database Delivery Learning program: www.red-gate.com/delivery

• Patterns and practices on Simple-Talk• Tutorials in Red Gate training academy

• www.youtube.com/user/RedGateVideos - for recorded seminars

Page 30: Automate Database Deployment - SQL In The City Workshop

Want to try the tools you’ve just seen? Come to our Hands-on Labs

Page 31: Automate Database Deployment - SQL In The City Workshop

Image sourcesAuthor Source Information

William Warby Flickr Glass Man - Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

Perry McKenna Flickr Headless Horse – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

William Warby Flickr Gears – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

Ross Harmes Flickr Gear for lightweight snow camping – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license.

Val Gardena – Gröden Marketing

FlickrFis Ski World Cup Val Gardena Gröden – Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license

Paul Pehrson Flickr Ice cream sundae - Flickr. This file is licensed under the Creative Commons Attribution 2.0 Generic license