4. Why put SQL into Version Control?
Lower Risk, Increased Quality
•Keeps history
•Documentation – Tie to issue tracker
•Makes processes repeatable
•Group changes (by feature)
•Continuous Integration and Deployment
•Portability
6. Transformation
Incremental changes to the database are saved and then can be run
in order to gain the desired database state
V0.0.1
0001
Database Create
Script
0002
Add Table
0003
Add Procedure
0004
Add Lookup Data
V0.0.2
State 1 State 2
Actual state is not saved, only how to get there
9. State
The full state of the database is stored for every version
State is saved, and tools are used to transform a
database from one state to another
V0.0.2
Schema
in source control
V0.0.1
Schema
in source control
V0.0.1
Database
Tool compares state
ofcurrent database
to state of schema
in version control
V0.0.2
Database
Transformation
Script or other
Method
Developers
Make
Changes
V0.0.3
Schema
in source control
Developers
Make
Changes
11. Which to Choose?
TRANSFORMATIONS
When to use
◦ Starting from scratch
◦ Simple model used for a single system
◦ Small team
◦ When a state tool is not available
STATE
When to use
◦ Existing, complex data models
◦ Multiple, interconnected databases
◦ Databases that are used by many systems
◦ Large Team
12. What is an SQL Database Project?
It is a Visual Studio Project specifically for storing database schema and
information.
What is a Visual Studio Project?
◦ "Projects are used in a solution to logically manage, build, and debug the items that make up
your application. The output of a project is usually an executable program (.exe), a dynamic-
link library (.dll) file or a module, among others.“
◦ For a Database Project, the output is a DACPAC (Data-Tier Application Package)
What is a Solution?
◦ "Solutions contain items that you need in order to create your application. A solution
includes one or more projects, plus files and metadata that help define the solution
as a whole."
14. Resources
Enrico Campidoglio
◦ NDC talk on Continuous Delivery for SQL
◦ http://www.ndcvideos.com/#/app/video/2531
◦ Features DbUP (https://www.nuget.org/packages/dbup/)
◦ .NETROCKS discussion on Continuous Delivery for SQL
◦ http://www.dotnetrocks.com/default.aspx?showNum=1079
Deborah Kurata
◦ Pluralsight video – Visual Studio Data Tools for Developers
◦ http://www.pluralsight.com/courses/visual-studio-data-tools-developers
Editor's Notes
Initial Questions
Who works with applications that use a database
Who works with applications that use an SQL Server databbase
Who works with creating or updating databases?
Who has their db code in version control?
Who has used an SQL Database Project?
Who has used SQL Server Database Tools in Visual Studio?
Who has used other tools like Redgate for comparing schema etc?
Initial Questions
Who works with applications that use a database
Who works with applications that use an SQL Server databbase
Who works with creating or updating databases?
Who has their db code in version control?
Who has used an SQL Database Project?
Who has used SQL Server Database Tools in Visual Studio?
Who has used other tools like Redgate for comparing schema etc?
Background:
Version controls rcs, visual source safe, cvs, subversion, mercurial, git
Client with sql database project
Background:
Version controls rcs, visual source safe, cvs, subversion, mercurial, git
Client with sql database project
Keeps History
Ability to get back to a point in time for debugging
Know what changed
Repeating process