Enabling Continuous Delivery with Database Practices



Similar documents
Nick Ashley TOOLS. The following table lists some additional and possibly more unusual tools used in this paper.

Practicing Continuous Delivery using Hudson. Winston Prakash Oracle Corporation

Continuous integration for databases using

Continuous integration for databases using Red Gate tools

Oracle Database 10g Express

A basic create statement for a simple student table would look like the following.

Continuous integration for databases using Redgate tools

DBdeployer. About the Speaker: CJ Estel, Operations Database Engineer CoverMyMeds

Create a Database Driven Application

ATTACHMENT 6 SQL Server 2012 Programming Standards

Agile Development and Schema Evolution. Schema Evolution Agile Development & Databases Case Study on the Herschel Project

Top 10 Oracle SQL Developer Tips and Tricks

SQL DBA Bundle. Data Sheet. Data Sheet. Introduction. What does it cost. What s included in the SQL DBA Bundle. Feedback for the SQL DBA Bundle

ALM: Continuous Integration. José Almeida, Microsoft

SUCCESFUL TESTING THE CONTINUOUS DELIVERY PROCESS

Continuous Delivery for Alfresco Solutions. Satisfied customers and happy developers with!! Continuous Delivery!

How To Create A Table In Sql (Ahem)

SQL Server Training Course Content

<Insert Picture Here> Application Change Management and Data Masking

Database Schema Deployment. Lukas Smith - lukas@liip.ch CodeWorks PHP on the ROAD

php tek 2006 in Orlando Florida Lukas Kahwe Smith

Best Practices for Application Release & Deploy Success Integrating Datical and IBM UrbanCode Deploy. What is slowing my application releases?

Oracle Database 12c Enables Quad Graphics to Quickly Migrate from Sybase to Oracle Exadata

Continuous Integration: Put it at the heart of your development

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

Phase Name 1 Initiation. 2 Requirements. 3 Design

Applying Agile SCM to Databases

DbSchema Tutorial with Introduction in SQL Databases

Vladimir Bakhov AT-Consulting +7 (905)

SQL Object Level Recovery Native 1.1

Solving the database deployment problem

Oracle Database 10g: Introduction to SQL

Database Build and Release will get started soon

OBJECT PERSISTENCE AND AGILE SOFTWARE DEVELOPMENT

Tracking Database Schema Changes. Guidelines on database versioning using Devart tools

SUCCESFUL TESTING THE CONTINUOUS DELIVERY PROCESS

Introduction to SQL and database objects

Develop your Database using Database Projects from SQL Server Data Tools (SSDT)

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Tips and Tricks in Migrating SharePoint

HP Quality Center. Upgrade Preparation Guide

Zero Downtime Deployments with Database Migrations. Bob Feldbauer

Continuous Delivery Workshop

A Migration Methodology of Transferring Database Structures and Data

Delivery. Continuous. Jez Humble and David Farley. AAddison-Wesley. Upper Saddle River, NJ Boston Indianapolis San Francisco

Data Archiving - Solutions, Challenges, Considerations & 3rd Party Tools. Putting Customer First

Managing Third Party Databases and Building Your Data Warehouse

Protecting Data Assets and Reducing Risk

Continuous Integration and Delivery. manage development build deploy / release

Continuous Delivery. Alejandro Ruiz

DevOps for the Mainframe

SQL 2: GETTING INFORMATION INTO A DATABASE. MIS2502 Data Analytics

Virtuoso Replication and Synchronization Services

ACCELERATE DEVOPS USING OPENSHIFT PAAS

Green Migration from Oracle

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

Oracle(PL/SQL) Training

Agile Techniques for Object Databases

Visual Studio Team Edition for Database Professionals. Woody Pewitt Developer Evangelist

Migrate Topaz databases from One Server to Another

Continuous Integration: Improving Software Quality and Reducing Risk. Preetam Palwe Aftek Limited

Migrations from Oracle/Sybase/DB2 to Microsoft SQL Server it s easy!

We ( have extensive experience in enterprise and system architectures, system engineering, project management, and

Best Approaches to Database Auditing: Strengths and Weaknesses.

Geodatabase Programming with SQL

Introduction to Triggers using SQL

Relational Database Concepts

Oracle Total Recall with Oracle Database 11g Release 2

Introduction to Agile Software Development Process. Software Development Life Cycles

Oracle Database Security Solutions

Improving database development. Recommendations for solving development problems using Red Gate tools

Oracle Database 10g: Program with PL/SQL

SQL. Short introduction

Oracle Database Development Standards For DNR Staff and Contractors. Table of Contents

IKAN ALM Architecture. Closing the Gap Enterprise-wide Application Lifecycle Management

Oracle Database 12c: New Features for Administrators

<Insert Picture Here> Edition-based redefinition: the key to online application upgrade

Exploring SQL Server Data Tools in Visual Studio 2013

IBM Campaign Version-independent Integration with IBM Engage Version 1 Release 3 April 8, Integration Guide IBM

Why Zalando trusts in PostgreSQL

WHITEPAPER. Improving database development

Oracle Database: Develop PL/SQL Program Units

Continuous Application Delivery From concept to reality. Carsten Lentz Sr. Solution strategist

Guide to Mobile Testing

Shadowbase Data Replication Solutions. William Holenstein Senior Manager of Product Delivery Shadowbase Products Group

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Why continuous delivery needs devops, and why devops needs infrastructure-as-code. Sriram 25-Oct-2012

NeXUS REPOSITORY managers

SQL Server 2016 New Features!

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

Measurable Improvements in E-Business Suite Application Management with OEM 12c

Automated performance testing using Maven & JMeter. George Barnett, Atlassian Software

Instructions Account creation & Management for Maine Schools

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Entity store. Microsoft Dynamics AX 2012 R3

Maintaining Stored Procedures in Database Application

DATABASE VIRTUALIZATION AND INSTANT CLONING WHITE PAPER

GETTING STARTED WITH CONTINUOUS DELIVERY. Lana wcgp.co

Continuous Delivery Software-Deployments ohne graue Haare. 3. April 2012 Corsin Decurtins

Transcription:

Enabling Continuous Delivery with Database Practices Pramod Sadalage @pramodsadalage ThoughtWorks Inc.

Agenda Why Continuous Delivery Collaboration with the data team Automation for data Refactoring databases Deploying database changes

Why Continuous Delivery?

To get fast feedback from users, release frequently

Reduce risk of releasing

Learning and responding to customer needs is critical

Achieve Continuous Delivery

Close collaboration between everyone involved in delivery

Extensive automation of all parts involved in delivery process

Reduce the gap between development and operations

How does continuous delivery apply to databases?

Collaboration techniques

Pair the DBA s and Developers

Version control all database scripts and artifacts

Automation techniques

Let developers provision application database

Andy Jai Laptop/Desktop Application Database

Continuously Integrate database changes

Database changes applied by DBA Team Check in application code and database migration scripts Local dev environment Integration environment PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build Dev Database

Check in application code and database migration scripts Local dev environment Integration environment PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build Dev Database

Check in application code and database migration scripts Local dev environment Integration environment Migration scripts (DBA) PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build

Check in application code and database migration scripts Local dev environment Migration scripts (DBA) Migration scripts Integration environment PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build Integration Database

Check in application code and database migration scripts Local dev environment Migration scripts (DBA) Migration scripts Integration environment PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build Integration Database

Check in application code and database migration scripts Local dev environment Migration scripts (DBA) Migration scripts Integration environment PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine PROD UAT QA Environment Dev DB Update and build Integration Database Apply migration scripts

Check in application code and database migration scripts Local dev environment Migration scripts (DBA) Migration scripts Integration environment Package Migration scripts PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine Artifacts War Jar PROD UAT QA Environment Dev DB Update and build Integration Database Apply migration scripts

Check in application code and database migration scripts Local dev environment Migration scripts (DBA) Migration scripts Integration environment Package Migration scripts Apply Migration scripts PROD UAT QA ANT Maven Gradle Rake Source Control Continuous Integration Engine Artifacts War Jar PROD UAT QA Environment Dev DB Update and build Integration Database Apply migration scripts War Jar

Benefits of CI with databases

Benefits of CI with databases Test application code and database at one place

Benefits of CI with databases Test application code and database at one place Generate code and database artifacts

Benefits of CI with databases Test application code and database at one place Generate code and database artifacts Integrate application and database changes in an independent environment

Benefits of CI with databases Test application code and database at one place Generate code and database artifacts Integrate application and database changes in an independent environment Show current state of application and database to all

DB artifacts in CI application artifact for build <<n>> database artifact for build <<n>>

Deployment

Deployment Database migration/upgrade should be a development time task not deployment time task

Deployment Database migration/upgrade should be a development time task not deployment time task Package all the migration scripts, during Continuous Integration cycle

Deployment Database migration/upgrade should be a development time task not deployment time task Package all the migration scripts, during Continuous Integration cycle Apply the migration scripts

Deployment Database migration/upgrade should be a development time task not deployment time task Package all the migration scripts, during Continuous Integration cycle Apply the migration scripts Deploy frequently to reduce risk

Database refactoring http://databaserefactoring.com/

A database refactoring is a small change to your database schema (the DDL, data, and DB code) which improves its design without changing its semantics.

A database refactoring is a small change to your database schema (the DDL, data, and DB code) which improves its design without changing its semantics.

A database refactoring is a small change to your database schema (the DDL, data, and DB code) which improves its design without changing its semantics. A database refactoring improves its design while retaining both its behavioral and informational semantics.

Timeline of Change

Timeline of Change Deploy new changes, migrate data, put in scaffolding code refactoring{ Start Implement the Expand

Timeline of Change Deploy new changes, migrate data, put in scaffolding code refactoring{ Start Implement the Transition Transition Period (old and new){ Expand

Timeline of Change Deploy new changes, migrate data, put in scaffolding code Remove old schema, scaffolding code Start Transition End refactoring{ Implement the Transition Period (old and new){ completed{ Refactoring Expand Contract

Keeping Old and New alive

Keeping Old and New alive DB Should be able to handle multiple versions of the application

Keeping Old and New alive DB Should be able to handle multiple versions of the application Create Interfaces in the database

Keeping Old and New alive DB Should be able to handle multiple versions of the application Create Interfaces in the database Wrap tables with views

Keeping Old and New alive DB Should be able to handle multiple versions of the application Create Interfaces in the database Wrap tables with views Create calculated columns

Keeping Old and New alive DB Should be able to handle multiple versions of the application Create Interfaces in the database Wrap tables with views Create calculated columns Create triggers to sync data

Expand Contract an example

Expand Contract an example Start name = Pramod Sadalage

Expand Contract an example Start name = Pramod Sadalage Expand name = Pramod Sadalage firstname = Pramod lastname = Sadalage

Expand Contract an example Start name = Pramod Sadalage Expand name = Pramod Sadalage firstname = Pramod lastname = Sadalage Contract firstname = Pramod lastname = Sadalage

More on expand contract

More on expand contract Start name = Pramod Sadalage

More on expand contract Expand Start name = Pramod Sadalage Without data migration name = Pramod Sadalage firstname = null lastname = null With data migration name = Pramod Sadalage firstname = Pramod lastname = Sadalage

More on expand contract Expand Start name = Pramod Sadalage Without data migration name = Pramod Sadalage firstname = null lastname = null With data migration name = Pramod Sadalage firstname = Pramod lastname = Sadalage

More on expand contract Expand Start name = Pramod Sadalage Without data migration name = Pramod Sadalage firstname = null lastname = null With data migration name = Pramod Sadalage firstname = Pramod lastname = Sadalage

More on expand contract Expand Start name = Pramod Sadalage Without data migration name = Pramod Sadalage firstname = null lastname = null With data migration name = Pramod Sadalage firstname = Pramod lastname = Sadalage Contract firstname = Pramod lastname = Sadalage

Simple scenario - DBDeploy ALTER TABLE Customer ADD firstname VARCHAR2(60); ALTER TABLE Customer ADD lastname VARCHAR2(60);! --//@UNDO! ALTER TABLE Customer DROP COLUMN firstname VARCHAR2(60); ALTER TABLE Customer DROP COLUMN lastname VARCHAR2(60);

With synchronized data ALTER TABLE Customer ADD firstname VARCHAR2(60); ALTER TABLE Customer ADD lastname VARCHAR2(60); CREATE OR REPLACE TRIGGER SynchronizeName BEFORE INSERT OR UPDATE ON Customer REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF :NEW.Name IS NULL THEN :NEW.Name := :NEW.firstname ' ' :NEW.lastname; END IF; IF :NEW.name IS NOT NULL THEN :NEW.firstname := extractfirstname(:new.name); :NEW.lastname := extractlastname(:new.name); END IF; END; /! //@UNDO

Migrate and Synchronize data ALTER TABLE Customer ADD firstname VARCHAR2(60); ALTER TABLE Customer ADD lastname VARCHAR2(60); UPDATE Customer set firstname = extractfirstname (name); UPDATE Customer set lastname = extractlastname (name);! CREATE OR REPLACE TRIGGER SynchronizeName BEFORE INSERT OR UPDATE. //@UNDO UPDATE Customer set name = firstname lastname WHERE name IS NULL; ALTER TABLE Customer DROP COLUMN firstname; ALTER TABLE Customer DROP COLUMN lastname;

Contract ALTER TABLE Customer DROP COLUMN name;! //@UNDO! ALTER TABLE Customer ADD name VARCHAR2(120); UPDATE Customer set name = firstname lastname WHERE name IS NULL;

Contract ALTER TABLE Customer DROP SET UNUSED COLUMN name;! //@UNDO When drop takes forever! ALTER TABLE Customer ADD name VARCHAR2(120); UPDATE Customer set name = firstname lastname WHERE name IS NULL;

Keep legacy apps happy ALTER TABLE Customer DROP COLUMN name; ALTER TABLE CUSTOMER ADD (name AS (generatename (firstname,lastname)) );! //@UNDO! ALTER TABEL Customer DROP COLUMN name; ALTER TABLE Customer ADD name VARCHAR2(120); UPDATE Customer set name = firstname lastname WHERE name IS NULL;! Virtual column in oracle is computed for every read

Another example

Migration script ALTER TABLE custordr rename to customerorder;! CREATE OR REPLACE VIEW custordr AS SELECT custordrid, ponumber, ordrdt, shipdate, sptoadid FROM customerorder ; --//@UNDO! DROP VIEW custordr; ALTER TABLE customerorder RENAME TO custordr;

data in migrations

data in migrations INSERT INTO businessunit ( businessunitid, name, regionid ) VALUES ( 22, 'John Doe Services', 1 ); INSERT INTO businessunit ( businessunitid, name, regionid ) VALUES ( 23, 'Bob Products', 1 ); INSERT INTO businessunit ( businessunitid, name, regionid ) VALUES ( 24, 'Carr Machinery', 1 );

data in migrations INSERT INTO currency ( currencyid, name, code ) VALUES ( 2, 'Canadian Dollar', 'CAD' ); INSERT INTO currency ( currencyid, name, code ) VALUES ( 3, 'Australian Dollar', 'AUD' ); INSERT INTO currency ( currencyid, name, code ) VALUES ( 4, 'EMU Euro', 'EUR' );

data in migrations DELETE FROM contact ct WHERE NOT EXISTS (SELECT 1 FROM customer p WHERE ct.contactid=p.contactid) and EXISTS (SELECT 1 FROM (SELECT customerid, COUNT(*) FROM contact WHERE customerid IS NOT NULL GROUP BY customerid HAVING COUNT(*) >1) ct2 WHERE ct.customerid=ct2.customerid);

Tips

Tips Large refactorings are risky

Tips Large refactorings are risky Sequence of many small refactorings can create the desired change

Tips Large refactorings are risky Sequence of many small refactorings can create the desired change Migration scripts should be checked in and run on local dev/ci/qa/uat/prod etc.

Tips Large refactorings are risky Sequence of many small refactorings can create the desired change Migration scripts should be checked in and run on local dev/ci/qa/uat/prod etc. Changes to data are also migrations

Tracking Changes

Tracking Changes Each change is a delta/migration script

Tracking Changes Each change is a delta/migration script Migration scripts are development time activity not deployment time tasks

Tracking Changes Each change is a delta/migration script Migration scripts are development time activity not deployment time tasks Package migration scripts for automated deployment

Tracking Changes Each change is a delta/migration script Migration scripts are development time activity not deployment time tasks Package migration scripts for automated deployment Same scripts for: developers, QA, UAT and Production

Continuous Delivery Deployment should be easy ant -propertyfile qa.properties upgrade ant -propertyfile live.properties upgrade

Thanks @pramodsadalage sadalage.com databaserefactoring.com