The document summarizes a presentation about including databases in a continuous integration/delivery process. It discusses treating database code like application code by placing it under version control and integrating databases into the DevOps software development pipeline. This allows databases to be built, tested, and released like other software through continuous integration, delivery, and deployment.
3. 10/30/17
1
Including the Database in a
DevOps Process
Steve Jones
Editor, SQLServerCentral
Redgate So;ware
@way0utwest
1. The database can be built*
2. The database can be tested*
3. The database can be released*
Three Takeaways
* like other software
Three Takeaways
5. 10/30/17
3
The Three Ways
• Principles underlying DevOps from Gene Kim
• Systems Thinking
• Amplify Feedback Loops
• Culture of ExperimentaTon and Learning
What is DevOps?
“DevOps is the union of people, process, and products to enable
conTnuous delivery of value to our end users.”
- Donovan Brown
6. 10/30/17
4
DevOps in Prac?ce
• Culture
• DBAs and developers working together
• AutomaTon
• Introduce tools to the database
• Lean
• make db changes simpler, evolve the db
• Measurement
• consider impact of db change
• Sharing
• understand how a db change impacts development and operaTons
The Applica?on Development Pipeline
OperaTons Development
Dev
Dev
Dev
Continuous integration
Build
Test
Publish
Sync
Trigger
Report
Artifact
repository
QA
Beta
Staging
ProducTon
7. 10/30/17
5
The Database Development Pipeline
OperaTons Development
Dev
Dev
Dev
Continuous integration
Build
Test
Publish
Sync
Trigger
Report
Artifact
repository
Shared
Dev
QA
Beta
Staging
ProducTon
Evolving Database Development
• The foundaTon is Version Control
• Treat the database code just like applicaTon code
• Capture our DDL (and DML)
• VCS OrganizaTon
• Can be same repo or separate repo (I prefer separate)
• Use a sub folder for the DDL
• Use Pull Requests for code review
8. 10/30/17
6
SQL and Version Control
• The process is
• Get changed code to a text file
• Commit to the VCS
• Comments are why changes were made, not what.
• OpTons for database DDL and DML
• ScripTng – SMO in SQL Server
• Third Party Tools
• File | Save
Demo
Store database code in a VCS
9. 10/30/17
7
Database Con?nuous Integra?on
• Database Build Process
• Pull code from VCS
• Order code according to rules of SQL
• Execute code on a database
• Run tests
• Package code for downstream release
• Use a Build Server just like applicaTon code
• TFS Build, Bamboo, Team City, Cruise Control, Jenkins, whatever
Database Tes?ng
• Tests must be automated
• Developers are not responsible for tesTng exisTng code
• Developers are responsible for tesTng their new code
• One test a day for new code will build a suite
• For SQL Server
• tSQLt
• Microso; Unit TesTng Projects
• DBUnit
• TSQLUnit
• Custom scripted tests
* For best results, use curated test data
10. 10/30/17
8
Demo
Implement ConTnuous IntegraTon
Generate the Update Script
• For code (stored procedures, funcTons, views, modules, etc.)
• Take latest version from VCS
• For tables
• Use Comparison or migraTon scripts to make changes.
• Tools
• Comparison tools (SQL Compare, etc)
• MigraTon Tools (ReadyRoll, FlywayDB, Liquibase, etc)
11. 10/30/17
9
Deploy the Code
• Use a consistent process
• Use automaTon where you can, use manual steps (documented)
where you cannot
• Slowly and conTnuously improve the process
• Use a Release Management Server
• Octopus Deploy
• TFS
• Bamboo
Demo
Release to Downstream Environments
12. 10/30/17
10
Release Issues
• Rollback
• For code (views, procs, funcTons) – Deploy the previous version
• For tables – Need custom code
• In general, I am a fan of dark deploys and roll forward
• Environment Data
• Data that varies by environment (queue names, security, etc)
• Script and deploy with deploy once scripts (maybe separate pipeline)
• Use tokens where possible and store config data in the environment
Summary
• Understand and apply the DevOps principles to the db
• Systems Thinking
• Feedback Loops
• ExperimentaTon and Learning
• Treat the database like applicaTon code
• Build the excepTons into your process
• Adapt to your environment
• Do more of what works
• Do less of what doesn’t
13. 10/30/17
11
The End
www.voiceofthedba.com
sjones@sqlservercentral.com
@way0utwest
/in/way0utwest
References
• You’re Doing DevOps Wrong - hnps://techcrunch.com/2016/07/04/youre-doing-devops-wrong/
• Codifying DevOps PracTces - hnp://www.jedi.be/blog/2012/05/12/codifying-devops-area-pracTces/
• 3 DevOps Principles to Apply to Your IT Team -
hnp://blogs.atlassian.com/2015/09/3-key-devops-principles-apply-team/
• DevOps DisTlled, Part 1: hnp://www.ibm.com/developerworks/library/se-devops/part1/index.html
• Closing the Gap Between Database Con6nuous Delivery and Code Con6nuous Delivery
- hnp://devops.com/2014/11/19/closing-gap-database-conTnuous-delivery-code-conTnuous-delivery/
- Where’s the Database in DevOps - hnps://www.red-gate.com/library/wheres-the-database-in-devops
- How do Databases Fit into DevOps -
hnps://blog.devopsguys.com/2015/02/19/how-do-databases-fit-into-devops/