Get Your Database 
Under Control 
Steve Jones 
Red Gate Software
Goals 
• Understand the value of version/source control 
for databases 
• Learn the tools, standards, patterns and best 
practices needed to manage a database from 
source control 
• Identify the necessary flow within a team needed 
to develop a database with source control
Get in touch 
Steve Jones 
www.voiceofthedba.com 
sjones@sqlservercentral.com 
@way0utwest
How many of you use version control for 
your application code? 
C#, ASP.NET, Javascript, VB.NET, etc.
How many of you use version control for 
your application code? 
database
Developers who refuse to use source/version 
control should be fired, simple as that.
Isn’t this too much trouble for my crappy 
experimental program?
Use source control because neither you 
nor your developers are perfect.
There are no excuses where 
you should not use it.
If it’s not in source control, 
it doesn’t exist.
“…your database should always 
be under source control right 
next to your application code.”
Reducing Risk
You’re using version control
You’re using version control
Use Something
Demo 
Getting started with databases in VCS
Additional Reasons for Source Control 
• Backup & Restore 
• Undo 
• Audit changes 
• Sandbox 
• Branching/Merging
Rules for Database Development 
Never use a shared database for development. 
Always Have a Single, Authoritative Source 
For Your Schema. 
Always Version Your Database.
The Ideal 
• Each developer has a 
dedicated environment with 
a copy of the schema and 
minimal data. 
• A shared integration environment where all 
developers’ changes are merged, available 
for developer testing.
Patterns and Practices 
• Get all your code 
– Object DDL 
– Assembly code 
– Security grants and revokes 
– Database configuration settings 
– Jobs for your application 
– Lookup data
Patterns and Practices 
• Commit Early, Commit Often 
• Use meaningful comments. Why, not what. 
• Check for changes often 
• Use common names and code patterns 
• Use tools 
• Branch Rarely
Teamwork
Teamwork 
• Communication 
o Team members need to be aware of (easily) 
what others are doing. 
• Coordination 
o Teams need to work in a way that 
complements each other.
Teamwork 
• Communication 
o Review each other’s code as you refactor 
o Share knowledge 
o Coordination 
o Decide on common code styles and names 
o And …
Teach
Demo 
The flow within teams
Reasons to Branch 
• Release 
• Hot Fixes 
• New Development 
• Integration 
• Feature set
Reasons to Branch 
• Release 
• Hot Fixes 
• New Development 
• Integration 
• Feature set
Demo 
Branching
Best Practices 
• Use version control for all code (including tests) 
• Commit early, commit often 
• Use tools 
o If it’s hard, people don’t do it 
• Train people 
• Build often
Automation
Automation 
Deployment 
package
deployment package 
1 
2 
3 
FAI 
L 
Development
Goals 
• Understand the value of version/source control 
for databases 
• Learn the tools, standards, patterns and best 
practices needed to manage a database from 
source control 
• Identify the necessary flow within a team needed 
to develop a database with source control
Thanks for coming 
www.voiceofthedba.com 
sjones@sqlservercentral.com 
@way0utwest 
Want to try the tools you’ve just 
seen? Come to our Hands-on Labs
References 
• http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your- 
database-items 
• http://www.codinghorror.com/blog/archives/001050.html 
• http://www.codinghorror.com/blog/2008/02/get-your-database-under-version- 
control.html 
• http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerData 
bases.aspx 
• http://odetocode.com/blogs/scott/archive/2008/01/30/three-rules-for-database- 
work.aspx 
• Check in early, check in often - 
http://www.codinghorror.com/blog/2008/08/check-in-early-check-in-often. 
html 
• http://betterexplained.com/articles/a-visual-guide-to-version-control/
Credits 
• https://www.flickr.com/photos/doug88888/8 
349818088/in/photostream/ 
• https://www.flickr.com/photos/8525214@N 
06/5132974421

Part of the DLM story: Get your Database under Source Control - SQL In The City

  • 1.
    Get Your Database Under Control Steve Jones Red Gate Software
  • 2.
    Goals • Understandthe value of version/source control for databases • Learn the tools, standards, patterns and best practices needed to manage a database from source control • Identify the necessary flow within a team needed to develop a database with source control
  • 3.
    Get in touch Steve Jones www.voiceofthedba.com sjones@sqlservercentral.com @way0utwest
  • 4.
    How many ofyou use version control for your application code? C#, ASP.NET, Javascript, VB.NET, etc.
  • 5.
    How many ofyou use version control for your application code? database
  • 6.
    Developers who refuseto use source/version control should be fired, simple as that.
  • 7.
    Isn’t this toomuch trouble for my crappy experimental program?
  • 8.
    Use source controlbecause neither you nor your developers are perfect.
  • 9.
    There are noexcuses where you should not use it.
  • 10.
    If it’s notin source control, it doesn’t exist.
  • 11.
    “…your database shouldalways be under source control right next to your application code.”
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    Demo Getting startedwith databases in VCS
  • 18.
    Additional Reasons forSource Control • Backup & Restore • Undo • Audit changes • Sandbox • Branching/Merging
  • 19.
    Rules for DatabaseDevelopment Never use a shared database for development. Always Have a Single, Authoritative Source For Your Schema. Always Version Your Database.
  • 20.
    The Ideal •Each developer has a dedicated environment with a copy of the schema and minimal data. • A shared integration environment where all developers’ changes are merged, available for developer testing.
  • 21.
    Patterns and Practices • Get all your code – Object DDL – Assembly code – Security grants and revokes – Database configuration settings – Jobs for your application – Lookup data
  • 22.
    Patterns and Practices • Commit Early, Commit Often • Use meaningful comments. Why, not what. • Check for changes often • Use common names and code patterns • Use tools • Branch Rarely
  • 23.
  • 24.
    Teamwork • Communication o Team members need to be aware of (easily) what others are doing. • Coordination o Teams need to work in a way that complements each other.
  • 25.
    Teamwork • Communication o Review each other’s code as you refactor o Share knowledge o Coordination o Decide on common code styles and names o And …
  • 26.
  • 27.
    Demo The flowwithin teams
  • 28.
    Reasons to Branch • Release • Hot Fixes • New Development • Integration • Feature set
  • 29.
    Reasons to Branch • Release • Hot Fixes • New Development • Integration • Feature set
  • 30.
  • 31.
    Best Practices •Use version control for all code (including tests) • Commit early, commit often • Use tools o If it’s hard, people don’t do it • Train people • Build often
  • 32.
  • 33.
  • 34.
    deployment package 1 2 3 FAI L Development
  • 35.
    Goals • Understandthe value of version/source control for databases • Learn the tools, standards, patterns and best practices needed to manage a database from source control • Identify the necessary flow within a team needed to develop a database with source control
  • 36.
    Thanks for coming www.voiceofthedba.com sjones@sqlservercentral.com @way0utwest Want to try the tools you’ve just seen? Come to our Hands-on Labs
  • 37.
    References • http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your- database-items • http://www.codinghorror.com/blog/archives/001050.html • http://www.codinghorror.com/blog/2008/02/get-your-database-under-version- control.html • http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerData bases.aspx • http://odetocode.com/blogs/scott/archive/2008/01/30/three-rules-for-database- work.aspx • Check in early, check in often - http://www.codinghorror.com/blog/2008/08/check-in-early-check-in-often. html • http://betterexplained.com/articles/a-visual-guide-to-version-control/
  • 38.
    Credits • https://www.flickr.com/photos/doug88888/8 349818088/in/photostream/ • https://www.flickr.com/photos/8525214@N 06/5132974421

Editor's Notes

  • #5 How many people in the audience use version control for their application code? Any of your front end code. * Note number
  • #6 Let’s ask the same question. How many of you use version control for your database code? For your tables, views, procedures? What about schemas? What about permissions and roles? What about cryptographic keys? * Note number and difference.
  • #7 Developers who refuse to use source/version control should be fired, simple as that. – top stack exchange Isn’t this too much trouble for my crappy experimental program. - Drupal Use source control because neither you nor your developers are perfect. – bottom stack exchange There are no excuses where you should not use it. - makeuseof If it’s not in source control, it doesn’t exist. - TroyHunt http://programmers.stackexchange.com/questions/122150/how-can-i-convince-cowboy-programmers-to-use-source-control http://www.makeuseof.com/tag/git-version-control-youre-developer/ http://www.mactech.com/articles/mactech/Vol.14/14.06/VersionControlAndTheDeveloper/index.html http://drupal.org/node/299067
  • #8 Developers who refuse to use source/version control should be fired, simple as that. – top stack exchange Isn’t this too much trouble for my crappy experimental program. - Drupal Use source control because neither you nor your developers are perfect. – bottom stack exchange There are no excuses where you should not use it. - makeuseof If it’s not in source control, it doesn’t exist. - TroyHunt http://programmers.stackexchange.com/questions/122150/how-can-i-convince-cowboy-programmers-to-use-source-control http://www.makeuseof.com/tag/git-version-control-youre-developer/ http://www.mactech.com/articles/mactech/Vol.14/14.06/VersionControlAndTheDeveloper/index.html http://drupal.org/node/299067
  • #9 Developers who refuse to use source/version control should be fired, simple as that. – top stack exchange Isn’t this too much trouble for my crappy experimental program. - Drupal Use source control because neither you nor your developers are perfect. – bottom stack exchange There are no excuses where you should not use it. - makeuseof If it’s not in source control, it doesn’t exist. - TroyHunt http://programmers.stackexchange.com/questions/122150/how-can-i-convince-cowboy-programmers-to-use-source-control http://www.makeuseof.com/tag/git-version-control-youre-developer/ http://www.mactech.com/articles/mactech/Vol.14/14.06/VersionControlAndTheDeveloper/index.html http://drupal.org/node/299067
  • #10 Developers who refuse to use source/version control should be fired, simple as that. – top stack exchange Isn’t this too much trouble for my crappy experimental program. - Drupal Use source control because neither you nor your developers are perfect. – bottom stack exchange There are no excuses where you should not use it. - makeuseof If it’s not in source control, it doesn’t exist. - TroyHunt http://programmers.stackexchange.com/questions/122150/how-can-i-convince-cowboy-programmers-to-use-source-control http://www.makeuseof.com/tag/git-version-control-youre-developer/ http://www.mactech.com/articles/mactech/Vol.14/14.06/VersionControlAndTheDeveloper/index.html http://drupal.org/node/299067