get your database under source control - sql in the city

38
Get Your Database Under Control Steve Jones Red Gate Software

Upload: red-gate-software

Post on 27-Nov-2014

159 views

Category:

Software


0 download

DESCRIPTION

Get your Database under Source Control. SQL In the City workshop 2014 with Steve Jones.

TRANSCRIPT

Page 1: Get your Database under Source Control - SQL In The City

Get Your Database Under Control

Steve JonesRed Gate Software

Page 2: Get your Database under Source Control - SQL In The City

Goals

• Understand the value of version/source control for databases

• Learn the tools, standards, patterns and best practices needed to manage a database from source control

• Identify the necessary flow within a team needed to develop a database with source control

Page 3: Get your Database under Source Control - SQL In The City

Get in touch

[email protected]

@way0utwest

Steve Jones

Page 4: Get your Database under Source Control - SQL In The City

How many of you use version control for your application code?

C#, ASP.NET, Javascript, VB.NET, etc.

Page 5: Get your Database under Source Control - SQL In The City

database

How many of you use version control for your application code?

Page 6: Get your Database under Source Control - SQL In The City

Developers who refuse to use source/version control should be

fired, simple as that.

Page 7: Get your Database under Source Control - SQL In The City

Isn’t this too much trouble for my crappy experimental

program?

Page 8: Get your Database under Source Control - SQL In The City

Use source control because neither you nor your

developers are perfect.

Page 9: Get your Database under Source Control - SQL In The City

There are no excuses where you should not use it.

Page 10: Get your Database under Source Control - SQL In The City

If it’s not in source control, it doesn’t exist.

Page 11: Get your Database under Source Control - SQL In The City

“…your database should always be under source

control right next to your application code.”

Page 12: Get your Database under Source Control - SQL In The City
Page 13: Get your Database under Source Control - SQL In The City

Reducing Risk

Page 14: Get your Database under Source Control - SQL In The City

You’re using version control

Page 15: Get your Database under Source Control - SQL In The City

You’re using version control

Page 16: Get your Database under Source Control - SQL In The City

Use Something

Page 17: Get your Database under Source Control - SQL In The City

Demo

Getting started with databases in VCS

Page 18: Get your Database under Source Control - SQL In The City

Additional Reasons for Source Control

• Backup & Restore• Undo• Audit changes• Sandbox• Branching/Merging

Page 19: Get your Database under Source Control - SQL In The City

Rules for Database Development

Never use a shared database for development.

Always Have a Single, Authoritative Source

For Your Schema.

Always Version Your Database.

Page 20: Get your Database under Source Control - SQL In The City

The Ideal

• Each developer has a dedicated environment with a copy of the schema and minimal data.

• A shared integration environment where all developers’ changes are merged, available for developer testing.

Page 21: Get your Database under Source Control - SQL In The City

Patterns and Practices• Get all your code

– Object DDL– Assembly code– Security grants and revokes– Database configuration settings– Jobs for your application– Lookup data

Page 22: Get your Database under Source Control - SQL In The City

Patterns and Practices

• Commit Early, Commit Often• Use meaningful comments. Why, not what.• Check for changes often• Use common names and code patterns• Use tools• Branch Rarely

Page 23: Get your Database under Source Control - SQL In The City

Teamwork

Page 24: Get your Database under Source Control - SQL In The City

Teamwork

• Communicationo Team members need to be aware of

(easily) what others are doing.

• Coordinationo Teams need to work in a way that

complements each other.

Page 25: Get your Database under Source Control - SQL In The City

Teamwork

• CommunicationoReview each other’s code as you

refactoro Share knowledge

o CoordinationoDecide on common code styles and

namesoAnd …

Page 26: Get your Database under Source Control - SQL In The City

Teach

Page 27: Get your Database under Source Control - SQL In The City

Demo

The flow within teams

Page 28: Get your Database under Source Control - SQL In The City

Reasons to Branch

• Release• Hot Fixes• New Development• Integration• Feature set

Page 29: Get your Database under Source Control - SQL In The City

Reasons to Branch

• Release• Hot Fixes• New Development• Integration• Feature set

Page 30: Get your Database under Source Control - SQL In The City

Demo

Branching

Page 31: Get your Database under Source Control - SQL In The City

Best Practices

• Use version control for all code (including tests)

• Commit early, commit often• Use tools

o If it’s hard, people don’t do it• Train people• Build often

Page 32: Get your Database under Source Control - SQL In The City

Automation

Page 33: Get your Database under Source Control - SQL In The City

Automation

Deploymentpackage

Page 34: Get your Database under Source Control - SQL In The City

deployment package1

2

3

Development

FAIL

Page 35: Get your Database under Source Control - SQL In The City

Goals

• Understand the value of version/source control for databases

• Learn the tools, standards, patterns and best practices needed to manage a database from source control

• Identify the necessary flow within a team needed to develop a database with source control

Page 36: Get your Database under Source Control - SQL In The City

Want to try the tools you’ve just seen? Come to our Hands-on Labs

www.voiceofthedba.com

@way0utwest

[email protected]

Thanks for coming

Page 37: Get your Database under Source Control - SQL In The City

References

• http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your-database-items

• http://www.codinghorror.com/blog/archives/001050.html• http://www.codinghorror.com/blog/2008/02/get-your-database-unde

r-version-control.html

• http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerDatabases.aspx

• http://odetocode.com/blogs/scott/archive/2008/01/30/three-rules-for-database-work.aspx

• Check in early, check in often - http://www.codinghorror.com/blog/2008/08/check-in-early-check-in-often.html

• http://betterexplained.com/articles/a-visual-guide-to-version-control/