Connecting to Microsoft SQL Server database from Oracle using Database Gateway for SQL Server
SQL in Version Control using SQL Server Database Projects
-
Upload
floydhilton -
Category
Software
-
view
93 -
download
7
Transcript of SQL in Version Control using SQL Server Database Projects
Get Your SQLintoVersion ControlUSING 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
•Makes processes repeatable
•Group changes (by feature)
•Continuous Integration and Deployment
•Portability
Two Version Control Processes for SQL
1. Transformation
2. State
TransformationIncremental changes to the database are saved and then can be run in order to gain the desired database state
V0.0.1
0001Database Create
Script
0002Add Table
0003Add Procedure
0004Add Lookup Data
V0.0.2
State 1 State 2
Actual state is not saved, only how to get there
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://github.com/sklose/NMigrations
•roundhouse•https://github.com/chucknorris/roundhouse
StateThe 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.1Database
Tool compares state of current database to state of schema in version control
V0.0.2Database
Transformation Script or other
Method
DevelopersMake
ChangesV0.0.3
Schemain source control
DevelopersMake
Changes
State Tools/Methods•Manual•Manually script schema objects and store in source control
•Entity Framework Migrations
•Redgate SQL Source Control
•SQL Server Database Project
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
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."
Demonstration – SQL Database Project
ResourcesEnrico 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