Successfully reported this slideshow.
Your SlideShare is downloading. ×

Getting Release Management Right for SQL Server

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 119 Ad

Getting Release Management Right for SQL Server

Download to read offline

You are ahead of the curve. You’ve learned that you need to put your database in source control and you’ve set up some sort of automated build and regression testing process. (Or you’ve been to my continuous integration session.)

However, your deployments are still expensive and risky. You find it hard to keep track of what has been deployed to each environment. You don’t have a great deal of confidence that the production database is still in line with source control. You may have heard of the automated deployment functionality in VSTS or Octopus Deploy but you haven’t tried it yet… at least not for SQL Server.

In this session I’ll automate a deployment pipeline in a couple of different ways. I’ll discuss the importance of your database model as well as repeatable upgrade scripts and discuss the pros and cons of different approaches to automation. I’ll also discuss how to monitor for and protect yourself from database drift.

You are ahead of the curve. You’ve learned that you need to put your database in source control and you’ve set up some sort of automated build and regression testing process. (Or you’ve been to my continuous integration session.)

However, your deployments are still expensive and risky. You find it hard to keep track of what has been deployed to each environment. You don’t have a great deal of confidence that the production database is still in line with source control. You may have heard of the automated deployment functionality in VSTS or Octopus Deploy but you haven’t tried it yet… at least not for SQL Server.

In this session I’ll automate a deployment pipeline in a couple of different ways. I’ll discuss the importance of your database model as well as repeatable upgrade scripts and discuss the pros and cons of different approaches to automation. I’ll also discuss how to monitor for and protect yourself from database drift.

Advertisement
Advertisement

More Related Content

Viewers also liked (20)

Similar to Getting Release Management Right for SQL Server (20)

Advertisement

Recently uploaded (20)

Getting Release Management Right for SQL Server

  1. 1. @_AlexYates_ #SqlSatIceland Getting Release Management right for SQL Server Alex Yates
  2. 2. @_AlexYates_ #SqlSatIceland Sérstakar þakkir til styrktaraðila SQL SATURDAY | #602 | REYKJAVIK 2017
  3. 3. @_AlexYates_ #SqlSatIceland DLM Consultant workingwithdevs.com alex.yates@dlmconsultants.com AlexYates @_AlexYates_
  4. 4. @_AlexYates_ #SqlSatIceland @_AlexYates_ | #SqlSatIceland
  5. 5. @_AlexYates_ #SqlSatIceland Agile Scrum Lean DevOps Iterative Continuous Delivery Developers
  6. 6. @_AlexYates_ #SqlSatIceland Monitoring Deployment Integrity Performance DBAs
  7. 7. @_AlexYates_ #SqlSatIceland @_AlexYates_ #SqlSatIceland
  8. 8. @_AlexYates_ #SqlSatIceland Farm Credit Services of America (FCSA) • 100 person IT team, 14 sub-teams • Database version control inconsistent • Deployment process manual • Delivery was slow and unreliable
  9. 9. @_AlexYates_ #SqlSatIceland Farm Credit Services of America (FCSA) • Growing test suite • Delivery faster and more reliable by catching issues early • Standardised source control process • Automated builds/deploys from source control
  10. 10. @_AlexYates_ #SqlSatIceland The deployment pipeline
  11. 11. @_AlexYates_ #SqlSatIceland Databases are hard • Schema changes vs existing data • Reference data vs production data • Teamwork and testing • Database drift (change outside process, e.g. production hot-fixes)
  12. 12. @_AlexYates_ #SqlSatIceland The deployment pipeline
  13. 13. @_AlexYates_ #SqlSatIceland The deployment pipeline
  14. 14. @_AlexYates_ #SqlSatIceland The deployment pipeline
  15. 15. @_AlexYates_ #SqlSatIceland The deployment pipeline
  16. 16. @_AlexYates_ #SqlSatIceland The deployment pipeline
  17. 17. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  18. 18. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  19. 19. @_AlexYates_ #SqlSatIceland Version Control
  20. 20. @_AlexYates_ #SqlSatIceland Version control - LMGTFY http://lmgtfy.com/?q=version+control
  21. 21. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  22. 22. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  23. 23. @_AlexYates_ #SqlSatIceland There’s more than one way to skin a cat @_AlexYates_ #SqlSatIceland
  24. 24. @_AlexYates_ #SqlSatIceland There’s more than one way to skin automate a cat @_AlexYates_ #SqlSatIceland
  25. 25. @_AlexYates_ #SqlSatIceland V1 V2
  26. 26. @_AlexYates_ #SqlSatIceland V1 V2 Migrations-based solutions
  27. 27. @_AlexYates_ #SqlSatIceland V1 V2 Model-based solutions
  28. 28. @_AlexYates_ #SqlSatIceland @_AlexYates_ #SqlSatIceland
  29. 29. @_AlexYates_ #SqlSatIceland “There's nothing more reliable than keeping track of exactly the scripts you intend to run, and running them, without trying to compare model and guess.” @_AlexYates_ #SqlSatIceland
  30. 30. @_AlexYates_ #SqlSatIceland “There's nothing more reliable than keeping track of exactly the scripts you intend to run, and running them, without trying to compare model and guess.” Paul Stovell, built Octopus Deploy http://docs.octopusdeploy.com/display/OD/SQL+Server+databases @_AlexYates_ #SqlSatIceland
  31. 31. @_AlexYates_ #SqlSatIceland “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.” @_AlexYates_ #SqlSatIceland
  32. 32. @_AlexYates_ #SqlSatIceland “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 https://blogs.msdn.microsoft.com/gertd/2009/06/05/declarative-database-development/ @_AlexYates_ #SqlSatIceland
  33. 33. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  34. 34. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  35. 35. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  36. 36. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  37. 37. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  38. 38. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  39. 39. @_AlexYates_ #SqlSatIceland Model vs migrations http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  40. 40. @_AlexYates_ #SqlSatIceland Model  Easier (less control)  Better for sprocs/functions  Better for large/distributed teams  Better for frequent changes  Better for dependency nightmares  Drift: rolled back  Better for development 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  Better for automation VS
  41. 41. @_AlexYates_ #SqlSatIceland DLMConsultants.com/model-vs-mig
  42. 42. @_AlexYates_ #SqlSatIceland Demo
  43. 43. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  44. 44. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  45. 45. @_AlexYates_ #SqlSatIceland Continuous Integration
  46. 46. @_AlexYates_ #SqlSatIceland What is CI?
  47. 47. @_AlexYates_ #SqlSatIceland What is CI? Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early. www.thoughtworks.com/continuous-integration
  48. 48. @_AlexYates_ #SqlSatIceland http://www.jamesshore.com/Blog/Continuous-Integration-on-a-Dollar-a-Day.html
  49. 49. @_AlexYates_ #SqlSatIceland Build servers
  50. 50. @_AlexYates_ #SqlSatIceland VCS Build Test Sync Upgrade scriptDatabase package Test results The automated build process
  51. 51. @_AlexYates_ #SqlSatIceland Builds/Tests are run on CI agents Builds/Tests are managed on CI server CI server How do build servers work?
  52. 52. @_AlexYates_ #SqlSatIceland DLMConsultants.com/ci
  53. 53. @_AlexYates_ #SqlSatIceland Demo
  54. 54. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  55. 55. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  56. 56. @_AlexYates_ #SqlSatIceland What is CD? Continuous Delivery (CD) is the natural extension of Continuous Integration: an approach in which teams ensure that every change to the system is releasable, and that we can release any version at the push of a button. Continuous Delivery aims to make releases boring, so we can deliver frequently and get fast feedback on what users care about. www.thoughtworks.com/continuous-delivery
  57. 57. @_AlexYates_ #SqlSatIceland Deploying databases, a history lesson SOURCE TARGET Process: Manual scripting
  58. 58. @_AlexYates_ #SqlSatIceland Deploying databases, a history lesson Process: Database comparison tool SOURCE TARGET
  59. 59. @_AlexYates_ #SqlSatIceland Deploying databases, a history lesson SOURCE TARGET Process: Generating the script is separate from manually executing the script
  60. 60. @_AlexYates_ #SqlSatIceland Deploying databases, a history lesson SOURCE Problem: Human error Doh! Human Error
  61. 61. @_AlexYates_ #SqlSatIceland Deploying databases, a history lesson SOURCE Problem: Drift (unscheduled or unmanaged changes) DriftDrift
  62. 62. @_AlexYates_ #SqlSatIceland What do you really need to deploy with confidence? Replacing a single deployment script with a credible release
  63. 63. @_AlexYates_ #SqlSatIceland What do you really need to deploy with confidence? 1. Source model Replacing a single deployment script with a credible release
  64. 64. @_AlexYates_ #SqlSatIceland What do you really need to deploy with confidence? 1. Source model 2. Target model Replacing a single deployment script with a credible release
  65. 65. @_AlexYates_ #SqlSatIceland What do you really need to deploy with confidence? 1. Source model 2. Target model 3. Upgrade script Replacing a single deployment script with a credible release
  66. 66. @_AlexYates_ #SqlSatIceland What do you really need to deploy with confidence? 1. Source model 2. Target model 3. Upgrade script 4. Change report SELECT ContactsID, ContactFullName, Address1, CountryCode, Replacing a single deployment script with a credible release
  67. 67. @_AlexYates_ #SqlSatIceland How should deployments work? 1. Does target match target model? 2. Run script 3. Does target match source model? TARGET
  68. 68. @_AlexYates_ #SqlSatIceland How should deployments work? 1. Does target match target model? 2. Run script 3. Does target match source model? TARGET
  69. 69. @_AlexYates_ #SqlSatIceland How should deployments work? 1. Does target match target model? 2. Run script 3. Does target match source model? TARGET
  70. 70. @_AlexYates_ #SqlSatIceland How should deployments work? 1. Does target match target model? 2. Run script 3. Does target match source model? TARGET
  71. 71. @_AlexYates_ #SqlSatIceland How should deployments work? 1. Does target match target model? 2. Run script 3. Does target match source model? TARGET
  72. 72. @_AlexYates_ #SqlSatIceland What should happen if anything goes wrong? 1. If target doesn’t match target model (or source model) – error and abort 2. If script fails – roll back transaction 3. If target doesn’t match source model after script execution – do not roll back but send warning, then roll-forward
  73. 73. @_AlexYates_ #SqlSatIceland Demo
  74. 74. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  75. 75. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  76. 76. @_AlexYates_ #SqlSatIceland Release Management
  77. 77. @_AlexYates_ #SqlSatIceland Release ManagementTools
  78. 78. @_AlexYates_ #SqlSatIceland How do release management tools work?
  79. 79. @_AlexYates_ #SqlSatIceland Deployments are run on RM agents Deployments are managed on RM server RM server How do release management tools work? Builds/Tests are run on CI agents Builds/Tests are managed on CI server CI server Just like a CI server!
  80. 80. @_AlexYates_ #SqlSatIceland RM server Test Staging Production AppDB AppDB AppDB Servers, environments, machines and agents
  81. 81. @_AlexYates_ #SqlSatIceland RM server Server RM software responsible for managing your deployments AppDB AppDB AppDB Servers, environments, machines and agents Test Staging Production
  82. 82. @_AlexYates_ #SqlSatIceland RM server App DB App DB App Machines physical or virtual boxes that you wish to deploy to AppDB AppDB AppDB Servers, environments, machines and agents Test Staging Production
  83. 83. @_AlexYates_ #SqlSatIceland Environments groups of machines that you will deploy to at the same time RM server App DB App DB App DB AppDB AppDB AppDB Servers, environments, machines and agents Test Staging Production
  84. 84. @_AlexYates_ #SqlSatIceland RM server Agents release management software that executes deployments on machines AppDB AppDB AppDB Servers, environments, machines and agents Test Staging Production
  85. 85. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB How database deployments should work Test Staging Production
  86. 86. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB DB server doesn’t actually need an agent How database deployments should work Test Staging Production
  87. 87. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB Install DB deployment tool and an RM agent on a machine (wherever you like) How database deployments should work Test Staging Production
  88. 88. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB RM server sends instruction to RM agent How database deployments should work Test Staging Production
  89. 89. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB RM agent calls DB deployment tool on its machine How database deployments should work Test Staging Production
  90. 90. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB DB deployment tool talks to target databases How database deployments should work Test Staging Production
  91. 91. @_AlexYates_ #SqlSatIceland RM server AppDB AppDB AppDB Some people install an agent and DB deployment tool on the RM server for simplicity How database deployments should work Test Staging Production
  92. 92. @_AlexYates_ #SqlSatIceland RM server AppDB If environments are isolated by firewalls you may need several DB deployment tool installations Production DB DB Test Staging App App How database deployments should work
  93. 93. @_AlexYates_ #SqlSatIceland In summary • Install the release management server on a test server or build server etc • Install agents that will deploy applications on the application servers themselves • Install agents that will deploy databases on a machine that has access to your target databases • Install DB deployment tool on the same machine as the agent that you will use to deploy your databases
  94. 94. @_AlexYates_ #SqlSatIceland Demo
  95. 95. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  96. 96. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  97. 97. @_AlexYates_ #SqlSatIceland Drift
  98. 98. @_AlexYates_ #SqlSatIceland
  99. 99. @_AlexYates_ #SqlSatIceland “When making changes directly on production, you are making a decision that the delay due to poor cycle time is more expensive than the risk of making a mistake.”
  100. 100. @_AlexYates_ #SqlSatIceland “When making changes directly on production, you are making a decision that the delay due to poor cycle time is more expensive than the risk of making a mistake.” AlexYates, built this slide
  101. 101. @_AlexYates_ #SqlSatIceland The bad stuff: • Accidental roll-backs (model) • Failed deployments (migrations) • Environment inconsistency (migrations)
  102. 102. @_AlexYates_ #SqlSatIceland Drift Strategies to help  Improve cycle time  Strict security policies  Monitor drift (play with DDL triggers)  Redgate DLM Dashboard (free) https://www.simple-talk.com/sql/database-administration/database-deployment-the-bits-database-version-drift/
  103. 103. @_AlexYates_ #SqlSatIceland Drift Strategies to help  Improve cycle time  Strict security policies  Monitor drift (play with DDL triggers)  Redgate DLM Dashboard (free) http://www.red-gate.com/products/dlm/dlm-dashboard/
  104. 104. @_AlexYates_ #SqlSatIceland Demo
  105. 105. @_AlexYates_ #SqlSatIceland Agenda Version control Model vs migrations Continuous integration Automating deployments Release management Drift
  106. 106. @_AlexYates_ #SqlSatIceland • Standardised VCS, CI and RM processes • FCSA delivering much more efficiently • FCSA process model for sister organisations • The team all have excellent CV’s Farm Credit Services of America (FCSA)
  107. 107. @_AlexYates_ #SqlSatIceland • Standardised VCS, CI and RM processes • FCSA delivering much more efficiently • FCSA process model for sister organisations • The team all have excellent CV’s Farm Credit Services of America (FCSA) http://www.codeaperture.io/2016/09/13/how-redgate-helped-define-our-process/
  108. 108. @_AlexYates_ #SqlSatIceland Siloed sparrows suck at DLM. @_AlexYates_ #SqlSatIceland
  109. 109. @_AlexYates_ #SqlSatIceland Heated hippos are closed minded. @_AlexYates_ #SqlSatIceland
  110. 110. @_AlexYates_ #SqlSatIceland Model  Easier (less control)  Better for sprocs/functions  Better for large/distributed teams  Better for frequent changes  Better for dependency nightmares  Drift: rolled back  Better for development 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  Better for automation VS Clever people consider options …
  111. 111. @_AlexYates_ #SqlSatIceland … use appropriate tools …
  112. 112. @_AlexYates_ #SqlSatIceland … and make pain on his smug face!
  113. 113. @_AlexYates_ #SqlSatIceland This stuff makes a big difference. http://www.codeaperture.io/2016/09/13/how-redgate-helped-define-our-process/ @_AlexYates_ #SqlSatIceland
  114. 114. @_AlexYates_ #SqlSatIceland DLMConsultants.com/rm
  115. 115. @_AlexYates_ #SqlSatIceland Takk fyrir að koma á SQL Saturday Iceland Sérstakar þakkir til styrktaraðila SQL SATURDAY | #602 | REYKJAVIK 2017 http://www.sqlsaturday.com/602/Sessions/SessionEvaluation.aspx
  116. 116. @_AlexYates_ #SqlSatIceland Questions? Links: DLMConsultants.com/rm Contact me: alex.yates@dlmconsultants.com
  117. 117. @_AlexYates_ #SqlSatIceland Image sources Author 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” Bit Boy Flickr The elephant in the room – 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 Taken by/property of Alex Yates Kitten, “There’s more than one way to skin a cat!” 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

×