Skip to main content

This post is from the XebiaLabs blog and has not been updated since the original publish date.

Last Updated Oct 31, 2016 — DevOps Expert

DevOps and the DBA: Best Practices in XL Deploy

DevOps

4n

As Agile practices and the DevOps movement transform delivery pipelines throughout the world, let's take a moment to reflect on the database administrator's role in pushing the latest features out the door. Here are six best practices for users of XL Deploy:

 

1. Remember that the DBA is part of the application development team(s).

The DBA coaches the developers on database architecture, proper SQL standards, Explains, etc. as they design, build, and test their code.  All team members operate under Agile principles.  

2. Standard environments that include the database should be able to be stood up quickly for testing the latest build.

In XL Deploy:  Include a dedicated database in every Environment to which the application is deployed  

3. Database configuration (DDL, SQL) is developed and saved as version-controlled code.

To paraphrase Gene Kim, Infrastructure-as-Code allows modern development practices to applied to the entire development stream to enable fast deployment, continuous integration, continuous delivery, and continuous deployment.  

4. Database changes are aligned with the application changes that need them.

In XL Deploy, an Application Package is a complete and environment-independent package, able to be deployed to any environment.  By complete, we mean that It includes all the binary artifacts, configuration settings, startup commands, etc. to get the application properly configured and running.  A dictionary/placeholder scheme is used to substitute environment-dependent values (port numbers, credentials, etc.) at deployment time. For example, an application needs a new index on a table, so the DDL for the index is part of the application change package to ensure that both are always deployed together. In XL Deploy:  Include sql.SqlScripts element in the application package.  This element is simply a zip file of lexicographically ordered scripts.  See below for an example. Database configurations used by more than one application can be managed by using XL Deploy's application dependencies set at the udm.DeploymentPackage object.  See https://docs.xebialabs.com/xl-deploy/concept/application-dependencies-in-xl-deploy.html.  

5. Database configuration changes are accumulated in new versions of the sql.SqlScripts object as they are developed.

At any point in time, the object can be deployed to a new or old environment and bring the database up to the state necessary for that version of the application.  So, in a brand new environment with just the DBMS software, XL Deploy would run all the scripts.  In an environment with a previous deployment(s), XL Deploy runs only scripts not run previously. Here is a simple example of the evolution of the scripts in sql.Scripts.Version 1 -- this version configures a database from the bare metal:
01-create-tables.sql
02-create-indexes.sql
03-grant-user-permissions.sql
Version 2: -- this version of the application requires a new table and its index
01-create-tables.sql
02-create-indexes.sql
03-grant-user-permissions.sql
04-create-new-table.sql
05-create-new-index.sql
Version 3: -- oops, the new index wasn't working, the app needs new-index-2 instead
01-create-tables.sql
02-create-indexes.sql
03-grant-user-permissions.sql
04-create-new-table.sql
05-create-new-index.sql
06-create-new-index-2.sql
Version 4: -- this iteration drop the bad index.  It may seem redundant to create and drop the index in the same set of scripts, but remember that this package may update an Environment whose current state is at Version 2 and we want to make we drop the bad index.
01-create-tables.sql
02-create-indexes.sql
03-grant-user-permissions.sql
04-create-new-table.sql
05-create-new-index.sql
06-create-new-index-2.sql
07-drop-new-index.sql

6. Rollback scripts are included to allow backout and undeployment.

XL Deploy uses a regex pattern to recognize which rollback script corresponds to which forward-going script.  Developers and DBAs should include these as they build the package of change.  Each one undoes the forward-going action, e.g. the first one drops the tables created by the first script.  With the rollbacks included, the package should look like this:
01-create-tables.sql
01-create-tables-rollback.sql
02-create-indexes.sql
02-create-indexes-rollback.sql
03-grant-user-permissions.sql
03-grant-user-permissions-rollback.sql
04-create-new-table.sql
04-create-new-table-rollback.sql
05-create-new-index.sql
05-create-new-index-rollback.sql
06-create-new-index-2-rollback.sql
07-drop-new-index-rollback.sql
07-drop-new-index-rollback.sql

References

http://www.slideshare.net/shivamaan/devops-common-use-cases-architectures-best-practices-48731462http://agilemanifesto.org/principles.htmlhttps://www.toadworld.com/platforms/oracle/w/wiki/11486.devops-as-an-agile-database-approachhttps://docs.xebialabs.com/xl-deploy/5.5.x/databasePluginManual.htmlhttps://docs.xebialabs.com/xl-deploy/concept/database-plugin.htmlThe DevOps Handbook, Gene Kim, Jez Humble, Patrick Debois, & John Willis, IT Revolution Press, LLC, 2016 

More from the Blog

View more
Feb 22, 2021

Reckoning DevOps’ role in the enterprise value stream

DevOps
If you’re a software or digital solutions company, you may use DevOps ...
Read More
Feb 10, 2021

Customer spotlight: Schneider avoiding bumps in the road with DevOps adoption

DevOps
Everyone wants to deliver software faster and more reliably. Companies ...
Read More
Jan 06, 2021

How testing automation can build a culture of QA while accelerating continuous delivery

DevOps
An organization’s level of automated test coverage is quickly emerging ...
Read More
Jul 30, 2020

Part 2: Is Technology Slowing Down Your Digital Transformation?

DevOps
In part one of this post, we shared insights from Andreas Prins’ webin ...
Read More
Contact Us