Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Get Your SQL
into
Version Control
USING MICROSOFT SQL SERVER DATABASE PROJECTS
Floyd Hilton
@fhilton
Boston Code Camp 23 - Thanks to our Sponsors!
Gold
Bronze
In-Kind Donations
Background
Why put SQL into Version Control?
Lower Risk, Increased Quality
•Keeps history
•Documentation – Tie to issue tracker
•Make...
Two Version Control Processes for SQL
1. Transformation
2. State
Transformation
Incremental changes to the database are saved and then can be run
in order to gain the desired database sta...
Basic Transformation Process
Custom Tool
V0.1.0
SQL Management Studio
Transformation Tools
•DbUp
•https://www.nuget.org/packages/dbup/
•Flyway
•http://flywaydb.org/
•Nmigrations
•https://githu...
State
The full state of the database is stored for every version
State is saved, and tools are used to transform a
databas...
State Tools/Methods
•Manual
•Manually script schema objects and store in source
control
•Entity Framework Migrations
•Redg...
Which to Choose?
TRANSFORMATIONS
When to use
◦ Starting from scratch
◦ Simple model used for a single system
◦ Small team
...
What is an SQL Database Project?
It is a Visual Studio Project specifically for storing database schema and
information.
W...
Demonstration – SQL Database Project
Resources
Enrico Campidoglio
◦ NDC talk on Continuous Delivery for SQL
◦ http://www.ndcvideos.com/#/app/video/2531
◦ Featu...
Upcoming SlideShare
Loading in …5
×

SQL in Version Control using SQL Server Database Projects

692 views

Published on

Talk for Boston Code Camp on 3/21/15.

Published in: Software
  • Be the first to comment

  • Be the first to like this

SQL in Version Control using SQL Server Database Projects

  1. 1. Get Your SQL into Version Control USING MICROSOFT SQL SERVER DATABASE PROJECTS Floyd Hilton @fhilton
  2. 2. Boston Code Camp 23 - Thanks to our Sponsors! Gold Bronze In-Kind Donations
  3. 3. Background
  4. 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
  5. 5. Two Version Control Processes for SQL 1. Transformation 2. State
  6. 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
  7. 7. Basic Transformation Process Custom Tool V0.1.0 SQL Management Studio
  8. 8. Transformation Tools •DbUp •https://www.nuget.org/packages/dbup/ •Flyway •http://flywaydb.org/ •Nmigrations •https://github.com/sklose/NMigrations •roundhouse •https://github.com/chucknorris/roundhouse
  9. 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
  10. 10. State Tools/Methods •Manual •Manually script schema objects and store in source control •Entity Framework Migrations •Redgate SQL Source Control •SQL Server Database Project
  11. 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. 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."
  13. 13. Demonstration – SQL Database Project
  14. 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

×