A Practical Approach to Version Control for SQL





















- Slides: 21
A Practical Approach to Version Control for SQL Server Steve Jones SQLServer. Central Redgate Software
Goals • Store database code in version control • Track code changes across time • Branch and merge changes to database code
Get in touch Steve Jones www. voiceofthedba. com sjones@sqlservercentral. com @way 0 utwest
Database Lifecycle Management Free Tool
What is version control? …any kind of practice that tracks and provides control over changes to source code. Software developers sometimes use revision control software to maintain documentation and configuration files as well as source code. (Wikipedia) Source Control = Version Control = Revision Control
Use version control because neither you nor your developers are perfect.
Getting Started • Create a location in a VCS respository • Script out objects to. sql files • Commit files
Workflow • Check out or open a file • Make changes (and test) • Save and Commit
Demo – Setup in Git
Benefits • Communication and collaboration • History • Undo • Get back to previous versions • Branching/merging • Single version of the truth • Building block for ALM
Demo – Changes, Migrations, and History
Teamwork • Work should be logically separated • Sandboxes should to be used • Developers’ work should not conflict But sometimes we work on shared databases, and …
Everyone Wants Locking
Demo – Locking Objects and Conflicts
Branching
Example of branching and merging #SQLinthe. City. UK #SQLinthe. City. US
Branches can be dangerous
#SQLinthe. City. UK #SQLinthe. City. US Demo – Branching and merging
Finally • Use a VCS, keep control of your code • Ensure everyone has the tools • Ensure everyone understands the process • Write comments for the future you
Goals • Store database code in version control • Track code changes across time • Branch and merge changes to database code
Questions? sjones@sqlservercentral. com #SQLinthe. City. UK #SQLinthe. City. US @way 0 utwest Fill in your evaluations Want to try the tools you’ve just seen? Visit the Redgate Booth