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.

KoprowskiT_Session2_SDNEvent_SourceControlForDBA

403 views

Published on

Session presented at Software Developers Network Conference in Zeist

Published in: Technology
  • Be the first to comment

KoprowskiT_Session2_SDNEvent_SourceControlForDBA

  1. 1. SQL Server Source Control for Beginners (database admin) Tobiasz Janusz Koprowski Independent Consultant, MCT, MVP
  2. 2. Introduction Tobiasz Janusz Koprowski Independent Consultant, MCT, MVP https://uk.linkedin.com/in/koprowskit @KoprowskiT http://koprowskit.eu/geek/
  3. 3. AGENDA • Source Control Systems • RedGate SQL Source Control • Version Controls – SVN, TFS, MERCURIAL • One or many? • DEMO • Video Games
  4. 4. Source Control Systems a definition: Revision control, also known as version control and source control (and an aspect of software configuration management), is the management of changes to documents, computer programs, large web sites, and other collections of information. Example history graph of a revision-controlled project; trunk is in green, branches in yellow, and graph is not a tree due to presence of merges (the red arrows). License: http://commons.wikimedia.org/wiki/File:Revision_controlled_project_visualization.svg
  5. 5. SOURCE CONTROL CONTINUOUS INTEGRATION: FUNDAMENTALS CONTINUOUS INTEGRATION: ADVANCED AUTOMATED DEPLOYMENT Four key stages of the deployment pipeline slides stolen from Alex Yates SQL Relay 2014 session http://bit.ly/1wMr3Su
  6. 6. SOURCE CONTROL  DB state vs upgrade scripts  Greenfields  Existing systems  Static data Four key stages of the deployment pipeline
  7. 7.  Select CI tooling  Automate builds as first step o Incremental o Complete  Create build Artefacts CONTINUOUS INTEGRATION: FUNDAMENTALS Four key stages of the deployment pipeline
  8. 8.  Write tests  Automate tests  Fast test cycles  Team disciplineCONTINUOUS INTEGRATION: ADVANCED Four key stages of the deployment pipeline
  9. 9.  Testing  Automation  Safety o Backups o Rollback strategyAUTOMATED DEPLOYMENT Four key stages of the deployment pipeline
  10. 10. Database Lifecycle Management Series 1. Database Source Control with Redgate’s SQL Developer Suite 2. Database Continuous Integration (CI) with Redgate’s DLM Automation Suite • Automated builds and tests 3. Automated Database Deployment with Redgate’s DLM Automation Suite
  11. 11. Database Lifecycle Management RELEASE MANAGEMENT CONTINUOUS INTEGRATION SOURCE CONTROL MANUAL MONITORING
  12. 12. Database Lifecycle Management Free Tool
  13. 13. SQL SOURCE CONTROL WORKS WITH or any source control system with a command line RedGate SQL Source Control
  14. 14. Deploy your database straight from source control • Avoid errors and stop those 4am deployments • SQL Source Control gives you an alternative: deploy from a canonical version of your database in source control. You’re working with a stable version, which cuts the risk of deploying incomplete or incorrect changes. • Deploy straight from your repository with SQL Compare Pro • You can deploy directly from your repository with SQL Compare Pro. It writes a deployment script for you in minutes, making your release safe and efficient. You can use it to generate rollback scripts too. RedGate SQL Source Control Deploy Features
  15. 15. Source control at your fingertips inside SQL Server Management Studio • It’s easy to record and share your code changes, because SQL Source Control runs inside SQL Server Management Studio. • You don’t have to stop what you’re doing or pass round handwritten change scripts. 1st of Six Source Control Key Features Source control at your fingertips inside SQL Server Management Studio
  16. 16. Source control your schemas and reference data • Store and share any SQL Server object and static data. Committing and updating takes two clicks in the Object Explorer. • To see what’s new, you can check changes down to the individual lines of SQL, with highlighted differences. 2nd of Six Source Control Key Features Source control your schemas and reference data
  17. 17. Roll back any changes you don't want • It’s simple to roll back and resolve conflictsfrom the Object Explorer. • This also gives you a risk-free sandbox. If you want to experiment on your database, go ahead. You can undo any changes you don't want to keep. 3rd of Six Source Control Key Features It's simple to roll back and resolve conflicts from the Object Explorer.
  18. 18. Handles referential integrity for you • When you commit or update, SQL Source Control maintains the referential integrity of your database for you. • It works out the right order for your changesand even deals with keys and constraints. • It uses the same engine as SQL Compare, the world’s most trusted tool for syncing database changes • . 4th of Six Source Control Key Features When you commit or update, SQL Source Control maintains the referential integrity of your database
  19. 19. Work on a central database or your own local copy • You and your team can work on a shared database or each use a local, dedicated copy. • SQL Source Control supports both models for database development. • Either way, it helps you share code, avoid conflicts, and see who’s doing what, so you can work without treading on each other’s toes. 5th of Six Source Control Key Features You and your team can work on a shared database or each use a local, dedicated copy
  20. 20. Lock objects you're working on • You can lock the object you're working on in SQL Server Management Studio with just one click, so your changes are safe from being overwritten. • Your team can see what's locked, as well as information on who locked it. 6th of Six Source Control Key Features Exclude objects with filters
  21. 21. • Source control for schemas and data • Push and pull database changes in SSMS • Check development history and access specific database versions • Store and share scripts to handle complex changes, such as column splits • Undo SQL Server changes • Exclude objects from source control using custom filters. • Supports SQL Server on Amazon RDS • View SQL differences between objects in a database and source control • Work with SQL Compare and SQL Data Compare to deploy databases directly from source control RedGate SQL Source Control
  22. 22. Reuirements • SQL Server Management Studio • 2005 (RTM, SP1, SP2, SP3, and SP4), • 2008 (RTM, SP1, SP2, R2, R2 SP1, and R2 SP2), • 2012, 2014 or 2016 (almost) • Windows Server 2008 R2, Windows Server 2012, Windows 7, or Windows 8/8.1 • .NET Framework 3.5 or later • MDAC 2.8+ • If you're using Team Foundation Server, you also need a compatible version of Team Explorer. Supported SQL Server versions • SQL Server 2005 (RTM, SP1, SP2, SP3 and SP4) • SQL Server 2008 (RTM, SP1, SP2, R2, R2 SP1, and R2 SP2) • SQL Server 2012 (RTM), SQL Server 2014 (RTM) • SQL Source Control doesn't support SQL Server 2000, SQL Express, SQL Azure or SSMS Express. RedGate SQL Source Control Requirements
  23. 23. RedGate SQL Source Control Permissions The permissions required to use SQL Source Control depend on your version of SQL Server and the objects in your database schema. If you have insufficient permissions, some objects may be missing from the change list. For example, user defined types may not be listed if you don't have permissions for the schema they belong to. • dbo permissions for the database you want to link to source control. • sysadmin permissions to commit or retrieve encrypted stored procedures. Additionally, if you're using SQL Server 2008 or later, we recommend: • SELECT permission for the system viewsys.sql_expression_dependencies. You may experience poor performance if you don't have this permission. • VIEW SERVER STATE permissions to commit or retrieve some encrypted objects
  24. 24. • SubVersion - control source system | LINK: https://subversion.apache.org/ • Free Repository | LINK: http://bettercodes.org/ • Paid Repository | LINK: http://cloudforge.com/ | LINK: https://www.assembla.com/subversion/ • Tortoise SVN - SVN client | LINK: http://tortoisesvn.net/downloads.html Version Control – with SVN
  25. 25. Version Control – working with SVN
  26. 26. Version Control – working with SVN / ca
  27. 27. • Mercurial – control sources system • | LINK: http://mercurial.selenic.com/ • TortoiseHg – client • | LINK: http://tortoisehg.bitbucket.org/ Version Control – working with CMD
  28. 28. Version Control – working with CMD
  29. 29. Version Control – working with CMD
  30. 30. http://bettercodes.org/
  31. 31. • Team Foundation Server – control sources system • MS Team Explorer – VS client • | LINK: http://msdn.microsoft.com/en-us/vstudio/ff637362.aspx Version Control – working with TFS
  32. 32. Version Control – working with TFS
  33. 33. Six steps: • create database • connect database to TFS/SVN/GIT {source control} • commit objects • get last version from TFS/SVN/GIT {source control} • change code • commit change to TFS/SVN/GIT {source control} Version Control – always in six steps
  34. 34. version control demo
  35. 35. Video http://bit.ly/1nuZwzh
  36. 36. Version Control – static data
  37. 37. Version Control – static data
  38. 38. Version Control – excluding • Get latest Updates the local working folder with latest version in source control. • Commit Commits all changes in the local working folder to source control. • Add Adds new files to the local working copy. Changes can then be committed to source control using the Commit command. • Edit Makes the local working copy of the files available for editing. Changes can then be committed to source control using the Commit command. • Delete Deletes the files from the local working copy. Changes can then be committed to source control using the Commit command. • Revert Undoes changes if an error occurs during a commit.
  39. 39. Version Control – historical data We can: • look into the logs • capture changes in SSMS You can't view history for databases linked to • Git • Mercurial • Working Folders
  40. 40. Version Control – historical data
  41. 41. Version Control – historical data
  42. 42. We can exclude tables when we don’t use special type of table in our development. Effect of this action – we don’t see those tables after operations: • Commit Changes • Get Latest • Undo Changes. Version Control – config files
  43. 43. Version Control – excluding
  44. 44. Version Control – excluding
  45. 45. • The key to avoiding database version control problems by Amy Burrows • http://www.red-gate.com/blog/object-locking • Locking objects in SQL Server by Amy Burows • https://www.simple-talk.com/blogs/2015/09/03/locking-objects-in-sql- server/?utm_source=twitter&utm_medium=social&utm_campaign=sqlsourcecontrol&utm_content=v4simpletalkreleaseblog_aburrows • Public Git hosting sites • https://git.wiki.kernel.org/index.php/GitHosting • White Papers: • http://www.red-gate.com/products/sql-development/sql-source-control/learn-more/white-papers • Case Study video of SQL Source Control & Continuous integration: • http://play.buto.tv/yhkvl • Product Manager& Developer session on Top tops for Continuous Integration: • http://play.buto.tv/TzmXD To learn more, go here…
  46. 46. SQL Source Control Documentation
  47. 47. Links http://bit.ly/1f76LLj
  48. 48. Links http://bit.ly/1iQEiIN
  49. 49. To learn more, go here. Learn a new Database Lifecycle Management skill in one day Want to take your next step in Database Lifecycle Management? These one-day workshops will teach you everything you need to get started with: •Database Source Control •Database Continuous Integration •Automated Database Deployment Each one’s available as a public workshop or on-site. If you'd like to book something on-site, contact us. http://www.red-gate.com/training/
  50. 50. Raffle for the end… KoprowskiT@windowslive.com I want SQL Developer Suite because…
  51. 51. QUESTIONS? http://www.sdn.nl/ @sdn_watch @KoprowskiT KoprowskiT@windowslive.com http://koprowskit.eu/geek/ https://uk.linkedin.com/in/koprowskit
  52. 52. SQL Saturday #434 Holland {Utrecht} Pre-Conference Full-Day Seminars PASS Nederland | Vianen, Nederland | Friday 25 september 2015 van 09:00 tot 17:00 (CEST) • Tobiaz Koprowski - WASD-A Journey from Zero to be Hero - Level 200 • Dejan Sarka - Data Mining Algorithms in SQL Server, Excel, R and Azure ML - Level 300 • Hugo Kornelis - Understanding Execution Plans - Level 400 Free Full Day Conference PASS Nederland | Vianen, Nederland | Saturday 26 september 2015 van 09:00 tot 17:00 (CEST)
  53. 53. Durf jij ook? Schrijf voor ons magazine of spreek ook op een volgend SDN event!

×