Get your Database under Source Control - SQL In The City
-
Upload
red-gate-software -
Category
Software
-
view
161 -
download
0
description
Transcript of Get your Database under Source Control - SQL In The City
![Page 1: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/1.jpg)
Get Your Database Under Control
Steve JonesRed Gate Software
![Page 2: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/2.jpg)
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
![Page 4: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/4.jpg)
How many of you use version control for your application code?
C#, ASP.NET, Javascript, VB.NET, etc.
![Page 5: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/5.jpg)
database
How many of you use version control for your application code?
![Page 6: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/6.jpg)
Developers who refuse to use source/version control should be
fired, simple as that.
![Page 7: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/7.jpg)
Isn’t this too much trouble for my crappy experimental
program?
![Page 8: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/8.jpg)
Use source control because neither you nor your
developers are perfect.
![Page 9: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/9.jpg)
There are no excuses where you should not use it.
![Page 10: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/10.jpg)
If it’s not in source control, it doesn’t exist.
![Page 11: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/11.jpg)
“…your database should always be under source
control right next to your application code.”
![Page 12: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/12.jpg)
![Page 13: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/13.jpg)
Reducing Risk
![Page 14: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/14.jpg)
You’re using version control
![Page 15: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/15.jpg)
You’re using version control
![Page 16: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/16.jpg)
Use Something
![Page 17: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/17.jpg)
Demo
Getting started with databases in VCS
![Page 18: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/18.jpg)
Additional Reasons for Source Control
• Backup & Restore• Undo• Audit changes• Sandbox• Branching/Merging
![Page 19: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/19.jpg)
Rules for Database Development
Never use a shared database for development.
Always Have a Single, Authoritative Source
For Your Schema.
Always Version Your Database.
![Page 20: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/20.jpg)
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.
![Page 21: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/21.jpg)
Patterns and Practices• Get all your code
– Object DDL– Assembly code– Security grants and revokes– Database configuration settings– Jobs for your application– Lookup data
![Page 22: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/22.jpg)
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
![Page 23: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/23.jpg)
Teamwork
![Page 24: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/24.jpg)
Teamwork
• Communicationo Team members need to be aware of
(easily) what others are doing.
• Coordinationo Teams need to work in a way that
complements each other.
![Page 25: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/25.jpg)
Teamwork
• CommunicationoReview each other’s code as you
refactoro Share knowledge
o CoordinationoDecide on common code styles and
namesoAnd …
![Page 26: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/26.jpg)
Teach
![Page 27: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/27.jpg)
Demo
The flow within teams
![Page 28: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/28.jpg)
Reasons to Branch
• Release• Hot Fixes• New Development• Integration• Feature set
![Page 29: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/29.jpg)
Reasons to Branch
• Release• Hot Fixes• New Development• Integration• Feature set
![Page 30: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/30.jpg)
Demo
Branching
![Page 31: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/31.jpg)
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
![Page 32: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/32.jpg)
Automation
![Page 33: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/33.jpg)
Automation
Deploymentpackage
![Page 34: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/34.jpg)
deployment package1
2
3
Development
FAIL
![Page 35: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/35.jpg)
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
![Page 36: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/36.jpg)
Want to try the tools you’ve just seen? Come to our Hands-on Labs
www.voiceofthedba.com
@way0utwest
Thanks for coming
![Page 37: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/37.jpg)
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-unde
r-version-control.html
• http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerDatabases.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/
![Page 38: Get your Database under Source Control - SQL In The City](https://reader033.fdocuments.net/reader033/viewer/2022061206/5476d2d5b4af9f247c8b4641/html5/thumbnails/38.jpg)
Credits
• https://www.flickr.com/photos/doug88888/8349818088/in/photostream/
• https://www.flickr.com/photos/8525214@N06/5132974421