Dr Greg Low Senior Consultant – Readify Pty Ltd DAT302.

Post on 23-Dec-2015

220 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Database Schema Versioning with Microsoft Visual Studio Team System for Database Professionals

Dr Greg LowSenior Consultant – Readify Pty Ltd

DAT302

Who am I?

Senior Consultant ReadifyHost of SQL Down Under PodcastMicrosoft MSDN Regional DirectorMicrosoft MVP for SQL ServerCo-organizer of CodeCampOzOrganizer of SQL Down Under CodeCampAuthor with Rational Press

Introduction to Visual Studio Team Edition for Database Professionals (aka DataDude)

The Project System

Unit Tests

Session Objectives and Agenda

Building and Deploying

What’s Coming Next?

Project Based Development

Disconnected Project ModelVisual Studio basedTeam Collaboration via TFS

Work Item TrackingProcess Integration

Automated Change Support

Comparison ToolsSchemaData

Source/Version ControlRefactoring

Limited as yetRename ObjectPower Tools add more

Unit Testing

VSTS Test Project InfrastructureData Generation

Auto-generationHistogram-basedUnderstands foreign key relationships

ExtensibleData GeneratorsTest Assertions

Build / Deployment

MSBuild IntegrationCreate New DBUpdate an Existing Schema

Introduction to Visual Studio Team Edition for Database Professionals (aka DataDude)

The Project System

Unit Tests

Session Objectives and Agenda

Building and Deploying

What’s Coming Next?

What is the source of truth?

Database Development Life Cycle

DatabaseProject

Import database schema

Reverse engineer existing .SQL script files

Create New Project

SQLScript

Database

ProjectTemplat

e

SQLServer

Database

Collection of .SQL file

containing T-SQL DDL fragments

Offline Schema Model

Parsing = SqlCodeDombased on Abstract Syntax Trees

Interpretation of Schema ModelSymbol listObject References (hard and soft dependencies)

.SQL Source

Parse

SqlCodeDom

Interpret

Schema Model

Database Development Life Cycle

DatabaseProject

Edit

Compare

Test

Build

Data Generation

Deploy

Refactor

Compare

Database Development Life Cycle

DatabaseProject

Import database schema

Reverse engineer existing .SQL script files

Create New Project

SQLScript

Database

ProjectTemplat

e

SQLServer

Database

DeploySQL

Script

SQLServer

Database

Build project

Deploy project

Project Model Summary

Database project = “truth” with regards to schema versioningCan be placed under source control.SQL script file is the canonical format usedChanges are tracked at object level

Indexes, constraints, triggers tracked independently of base tableProvides high granularity for change tracking

Build and Deploy the Project

demo

Introduction to Visual Studio Team Edition for Database Professionals (aka DataDude)

The Project System

Unit Tests

Session Objectives and Agenda

Building and Deploying

What’s Coming Next?

Data Generation

Where does test data come from?Production data?Scrubbed production data?Typed in manually?Auto-generated?

Unit Tests

Have been hard to do with databasesSQL 2k5 Database Snapshots helpfulLeverage VSTS Unit Test InfrastructureExtensible test assertions

Data Generation and Unit Tests

demo

Introduction to Visual Studio Team Edition for Database Professionals (aka DataDude)

The Project System

Unit Tests

Session Objectives and Agenda

Building and Deploying

What’s Coming Next?

Build Cycle

DBA

DBDev

ProductionDatabase

StagingDatabase

SCM

Daily Build Test

Get Latest

TestDatabase

DailyBuild

Output

Can also beused in a “Continuous”build environment

Trust Boundary

Deploy The Project Environment

DBA

Sync fro

m La

bel

DBDev

ProductionDatabase

StagingDatabase

SCM

SQLDeploy ScriptBuild

Deploy

Refine deploy scriptVerify

Trust Boundary

DatabaseProject

Benefits of This Approach

Managed, project oriented evolution of

database schemaApplication and database schema are managed togetherWork in “isolation”, deploying only when changes verifiedLeverage VSTS work item tracking and process guidance increases team collaboration and unity

Build & Deploy

DatabaseProject

TargetDatabas

e

SQLScript

Deploy

Build

Difference based build script

Project State“What you want”

Current State“How it is right

now”

Execute Incremental Update

Script

Command Line Building

All steps are implemented as MSBuild tasks

SqlBuildTaskSqlDeployTaskDataGeneratorTask

More tasks coming in Power ToolsAll project properties can be overwritten at the command line

Command Line Build

Using the project settings:msbuild NorthwindOnline.dbproj /t:build

Overwriting project settingsmsbuild NorthwindOnline.dbproj /t:build /p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;" /p:TargetDatabase="NorthwindOnlineTestDB"

Command Line Deployment

Using the project settings:msbuild NorthwindOnline.dbproj /t:deploy

Overwriting project settings:msbuild NorthwindOnline.dbproj /t:deploy /p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;"/p:TargetDatabase="NorthWind"

Provisioning Multiple Servers

How can I deploy to multiple targets?The Database Project only understand a single target server/database at the time

for each server+database combination in list{

SqlBuildTask SqlDeployTask

}

Building from the Command Line

demo

Team Foundation Build

Build Server infrastructureFully integrates with Team Foundation ServerExtensible

Based on MSBuildFully extensible XML-based scriptingRich Command-line supportRemote and Desktop build support

Have to install Team Build separatelyNot installed as part of Team Foundation Server

Team Foundation Build ArchitectureTF Client

Team Build Client

Team Build

Team BuildStore

Build Server

Source Control

Build Configuration files - MSBuild Scripts

MSBuild Scripts

and targets

Build sources and scripts

Build Events

Build events

Build request and Reports

Team Build Service

Team Build logger Build and

Test data

Build start/stop

Work item Tracking

Open and Update bugs

BuildDrop site

TFS Data Tier

TF Warehouse

Static Analysis& Testing

TFS

Introduction to Visual Studio Team Edition for Database Professionals (aka DataDude)

The Project System

Unit Tests

Session Objectives and Agenda

Building and Deploying

What’s Coming Next?

Service Pack 1

Now downloadable

Power Tools

New RefactoringsMove schemaDisambiguate (fully aliases references)Wild-card expansion (*)Generated schema deployment scripts based on refactoring logs (separates sp_name and TRANSFER SCHEMA)Strongly-typed dataset refactoring (if in same solution file)

Power Tools

New MSBuild TasksSchema compareData Compare

Data GeneratorRegular expression string and data bound generatorsRegex editor has generator for check constraintsStream-based data-bound generator (pulls one row at a time)

Power Tools

Dependency Tree ViewerT-SQL Static Code Analysis (ala FxCop)API Access to Schema View

Leveraged by CA Erwin R7.2 SQL Script Pre-Processor

Expands variables and include files

Summary

Excellent addition to VSTSAllows database schemas and versioning to be managed along with application codeExtensible

ResourcesMSDN Forum: Visual Studio Team System - Database Professionals

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=725&SiteID=1

White papersWhat Microsoft Visual Studio 2005 Team Edition for Database Professionals Can Do for YouA Security Overview of Microsoft Visual Studio 2005 Team Edition for Database ProfessionalsDatabase Unit Testing with Team Edition for Database Professionals

Sampleshttp://www.codeplex.com/vsdbpro

Trial Editionhttp://www.microsoft.com/downloads/details.aspx?familyid=7de00386-893d-4142-a778-992b69d482ad&displaylang=en

Gert’s Bloghttp://blog.msdn.com/gertd

SQL Down Under Code Camp

Biggest SQL Server community event in Australia14 SQL Server sessions over two daysSpecial guest presentation from Kevin Kline

President of PASS, Director of Technology – Quest Software

When?Weekend of the 13th and 14th of October

Where?Charles Sturt University, Wagga Wagga

What does it cost?This event is FREE

http://www.sqldownunder.com

SQL Server User Groups

Best place to learn about SQL Server for FREEUser Groups in most capital citiesGreat networking opportunityhttp://www.sqlserver.org.au

Evaluation Forms

greg.low@readify.nethttp://msmvps.com/greglowhttp://www.sqldownunder.com

Questions?

Thank You!

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

top related