Whitepaper 3 reasons to invest in database source control
3 reasons to invest in database source control Introduction This whitepaper discusses the three reasons why your business should be investing in database source control: disaster prevention, keeping your team in sync and conforming to best practice. Source control is a long-established part of the development process for application code, but not for database code. Historically, database source control has required complex, custom workarounds but this is no longer the case. This whitepaper provides a high-level overview of how database source control can improve the effectiveness of database development. What is source control? Source control (or version control), is a system which tracks and retains an incremental history of changes to a set of files. Source control systems can be used in many types of project, ranging from application development to website development. The content may include source code within application development, or files such as architecture diagrams and documentation. The fundamental value of source control is that it allows teams to maintain a single, authoritative, shared repository of project resources, while enabling multiple individuals to work on the same codebase, without having to constantly send files back and forth. www.red-gate.com 2
1 - Preventing disasters 1. Preventing disasters The term disaster is relative, but for a development team, days, or even hours of lost time can be disastrous, particularly if the consequences extend to missed deadlines or downtime of production systems. There are many circumstances where an innocent database change can lead to an overwritten table or data loss, or a difficult-to-find bug. Even in a project where a single developer is modifying a simple database, changes can introduce bugs and regressions. This problem is compounded within team based development; if one developer accidentally overwrites another s work, development can grind to a standstill. Multiple developers working simultaneously on a database can routinely encounter conflicts and broken dependencies, resulting in wasted development time and a slower, less efficient development cycle. A properly implemented database source control system reduces the likelihood of disasters by increasing the transparency of the development process and helping developers catch bugs earlier. Moreover, if problems do occur, source control allows your team to quickly reverse their effects. Improved visibility Without source control it is difficult to track database changes, so sharing them becomes an uncertain, manual procedure. However, source control helps developers prevent problems such as overwriting colleagues work by providing a detailed history of database changes. Developers can easily track who changed what, when they did it, and why. If they find a conflict, they can compare the differences before deciding whether to commit their change. If important code is inadvertently overwritten, it s a quick procedure to undo a change or revert a database to a previous version. Roll back to previous versions With the improved visibility provided by database source control there is less likelihood of changes being overwritten, or dependencies broken. However, if this does occur, developers can instantly undo a particular change or revert the database to a chosen previous version. www.red-gate.com 3
1 - Preventing disasters Produce higher quality code with source control Unit testing (whereby small units of code are tested in isolation) is increasingly commonplace within application development, as it allows teams to develop higher quality source code in less time. Unfortunately, database developers have not been able to benefit from this, as the nature of database development has rendered unit testing unfeasible. Red Gate now offer SQL Source Control and SQL Test, which combine to allow unit testing for databases. SQL Source Control allows each developer to have a local sandboxed copy of the database on their machine, permitting risk free development and unit testing with SQL Test before changes are shared. Consequently, bugs can be identified and fixed much earlier in the development cycle by the developer who is most familiar with that code. Ultimately, implementing source control and unit testing within database development leads to higher quality code, and minimizes the likelihood of disasters such as data loss or costly delays. SQL Test lets developers thoroughly test their database changes before sharing their work. www.red-gate.com 4
2 - Keep your team in sync 2. Keep your team in sync Successful software development depends on successful coordination of the development team, and increasingly this means shifting towards a leaner, more agile style of development. It is now more important than ever for your team to work as efficiently as possible. Database source control removes many obstacles from team collaboration, allowing your team to ship a higher quality product with fewer bugs, on time. Resuming partially completed work Without source control, resuming partially completed work can be slow and cumbersome. Developers must spend time learning each other s code and understanding the status of the work before it can be restarted. These problems are amplified for large or distributed development teams. Source controlled database development makes the process significantly more efficient by maintaining detailed change histories and allowing developers to easily document their changes as they work. Change management Without source control, workarounds are needed to ensure that your developers have the latest database changes. Typically, this means discussing updates through IM or email, and stopping development work until other team members reply. Work may be shared using backups and restores, or by constructing a custom, home-grown solution. Using database source control instead of these wasteful processes allows developers to get the latest changes and commit their own in seconds. Furthermore, automatic versioning makes it easier for teams to find and resolve conflicts and to document dependency chains. Database source control minimizes downtime and removes inefficiencies from the development process, allowing your team to work together much more effectively. Ultimately, this will result in higher quality development in a shorter time. In addition, source control makes it easier to move towards leaner, more agile development practices. www.red-gate.com 5
3 - Conform to best practice 3. Conform to best practice Conforming to increasingly stringent regulatory requirements has become difficult and time consuming. Many organizations unknowingly breach complex legal requirements because they are ambiguously worded or challenging to adhere to. While regulatory compliance is likely to affect many areas of your organization, database development and administration is arguably amongst the areas most seriously affected. Your organization s databases are where much, if not all, of your critical business information lives. Consequently, compliance auditors will usually require you to account for all changes to a database, and detail all those with access to it. Unsurprisingly, organizations operating in different industries and geographic locations are subject to differing levels of regulatory requirements. As a minimum it is best practice to ensure you have processes in place to: Manage how schema and data changes are made Document schema changes Maintain a detailed history of who made which changes Document database schema and access permissions Revert to previous versions if problems occur For database developers, collecting and documenting this information has traditionally been a manual, time-consuming process, and one that is often overlooked. Database source control and compliance Implementing source control within your database development process can make it significantly easier to meet regulatory compliance. The change tracking provided by source control is the first step to making your database compliant, and an essential step in maintaining a robust audit trail. A source controlled database can provide the following benefits: Documentation of schema changes as they are made A detailed history of who made which changes and why A repository of previous database versions www.red-gate.com 6
3 - Conform to best practice Database source control allows you to easily maintain a complete history of database changes. In addition to this, database source control simplifies the separation of duties required by some regulations such as the Sarbanes-Oxley Act (SOX). In essence, this requires that different developers are assigned to separate areas of the development process. For example, a developer who is responsible for a particular unit of code is not permitted to sign off on its testing or deploy it to production. Source control simplifies the process of creating an audit trail by allowing developers to work with local sandboxed versions of databases and automatically tracking which changes were made by which user. Conforming to best practice and regulatory requirements is a particularly difficult task for database developers, due to stringent requirements and the limitations of developer tools. However, implementing database source control can greatly simplify the process of maintaining a robust audit trail and is the first step to getting your database ready for compliance. www.red-gate.com 7
Implementing database source control with SQL Source Control Implementing database source control with SQL Source Control We have highlighted three important business benefits of source control: it helps prevent costly development disasters, enables your team members to work more effectively with each other and helps you conform to best practice. However, for source control to be a truly valuable investment, it needs to be both straightforward to implement and unobtrusive to use. SQL Source Control from Red Gate plugs into your existing source control system to give you and your team the benefits of database source control, while being easy to adopt and use: www.red-gate.com 8
Implementing database source control with SQL Source Control Prevent disasters: Develop within a sandbox for risk free experimenting Create higher quality code by using SQL Source Control and SQL Test to manage and run unit tests Keep your team in sync: Allow developers to easily get the latest version of objects from source control Improve development visibility with clear, visual comparisons of database changes Commit new, edited, and dropped objects to source control with a couple of clicks Minimize both developer downtime and inefficiencies in your development process Conform to best practice: Store a complete record of development history to comply with regulatory requirements Effortlessly access specific database versions Keep track of who changed what, when, and why Document database changes from within the development environment Implement easily: SQL Source Control is an add-in for SQL Server Management Studio, which allows your developers to use source control within their development environment SQL Source Control supports Team Foundation Server (TFS), Subversion (SVN), SourceGear Vault, Mercurial, Perforce, Git, or any source control system with a capable command line SQL Source Control works with a shared central database or individual, local copies, whichever model your team prefers Unlike custom solutions, SQL Source Control is quick to learn and simple to use www.red-gate.com 9
Further resources Further resources These resources are also available if you d like to read more about database source control: o o o o The ebook SQL Server Team based Development is available as a free download For additional information, or to download a 28-day evaluation of SQL Source Control, visit Red-Gate.com SQL Test is currently available as a free preview release To arrange a free live demo of SQL Source Control for either you or your team, visit Red-Gate.com www.red-gate.com 10