180 likes | 191 Views
Learn the importance of source control for databases in a development environment, comply with code development best practices, and incorporate testing and continuous integration into database development processes.
E N D
T-SQL Deployment and Continuous Integration Best Practices Grant Fritchey – Red Gate Software
Goals • Learn the importance of source control for databases in a database team development environment • Show how database development can comply with code development best practices • Learn how to incorporate testing and support of a continuous integration environment into database development processes
Grant Fritchey • Product Evangelist for Red Gate Software • Email: grant@scarydba.com • Twitter: @gfritchey • Blog: scarydba.com
The Database “Problem” • Information persistence layer • Businesses like their data • Keeping that data in place can be work • Which is the start of the “problem” • Object Relational Impedance Mismatch • Which is the rest of the “problem”
The Database “Solution” • Treat it as much like code as possible • Do the following • Work directly with the team • Define a repeatable process • Put the database into source control • Put tests in place to validate the database • Automate as much of the process as possible • Follow the local development paradigm as much as possible
The Team • Roles • Application Developer • Database Developer • Database Administrator • Report Writer • ? • Communication • Collaboration • Remember, it’s a common goal • Contention
Process: Team Glue • You must define a process • It’s your process, you define it • Management buy-in • Write the process down • And publish it • Review process regularly • Follow the process • Exceptions have to be exceptional • The process applies to everyone • No, DBAs, you’re not that special
Source Control • Known states • Production • Source control • Tighter integration with Developers • History of changes • Auditing • But, requires discipline • Always work through source control • Always deploy from source control • Only deploy from source control
Testing • Test Driven development • Improved quality • Continuous integration • Testing needs • Automation • Isolation • Repeatability
Automation • Because you have work to do • Multiple developers • Multiple servers • Tools you know • TSQL • Powershell • Command line • 3rd Party
Continuous Integration • Quality control • Identify issues early • Build from source control • Automatic process • Scheduled or Triggered • Make the build self-testing • Publish the results
Continuous Integration runs each time you commit a change to source control • Unit test database code • Validate database upgrade scripts • Validate database creation scripts • Generate database upgrade scripts • Generate creation scripts • We also build a database that can be used by the application for its own unit tests • Optionally build and update dev and test environments If any part of the CI process fails, the ‘build’ is deemed broken and developers are alerted immediately Each time the build is successful, publish updated database documentation
Tool Set • Source Control • Flavors don’t matter • Make it work for you • Use labeling (or equivalent) • Use branching (or equivalent) • Build Tool • SSMS • Visual Studio • 3rd Party • CI Monitoring Tool • TeamCity • CruiseControl • Custom • Other
Demo • More than one way to do this
Goals • Learn the importance of source control for databases in a database team development environment • Show how database development can comply with code development best practices • Learn how to incorporate testing and support of a continuous integration environment into database development processes
Resources • Scarydba.com/resources • http://knowscrum.com/benefits-of-continuous-integration-in-scrum-best-practices-in-scrum/ - Benefits of CI in Scrum • http://www.codinghorror.com/blog/2006/10/the-build-server-your-projects-heart-monitor.html - The Build Server, Your Projects Heart Monitor • http://martinfowler.com/articles/continuousIntegration.html - Martin Fowler on CI • http://en.wikipedia.org/wiki/Continuous_integration- Wikipedia CI • http://www.real-sql-guy.com/search/label/Source%20Control – Automated Source Control • http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/- Rob Sullivan – Seeing Red Change to Green • http://www.simple-talk.com/content/article.aspx?article=1247– Troy Hunt – Continuous Integration for SQL Server Databases
Grant Fritchey • Product Evangelist for Red Gate Software • Email: grant@scarydba.com • Twitter: @gfritchey • Blog: scarydba.com
Questions? How would you… ? What happens when… ? Why does… ? When do I… ?