How to: Deploy an Older Version of a Version-controlled Database

If you put a database project and its related unit tests under version control, you can easily retrieve and deploy older versions of that project. You might have to deploy an older version of a database project, for example, to roll back a production database to an older version or to develop a fix for a customer who has an older version of your application. If you are using a version control system such as Visual Studio Team Foundation Server that supports applying a named label to a group of files, you can easily retrieve and deploy an older version of the database. If your version control system does not support labels, you can also retrieve specific versions of individual files, or you might also be able to retrieve the versions of files from a specific date. 

Note

This topic gives the syntax for Team Foundation version control and for Visual SourceSafe. Refer to the documentation for your version control software if you are using some other application.

To retrieve and deploy an older version of your database project

  1. If you are using Team Foundation version control, you can find a labeled version of your project and retrieve the files to your local workspace. If you do not have labels available, you can still get specific versions of files. You can also get the versions of files from a specific date. For more information, see Get the Source for Your Team Project.

  2. (Optional) To review your deployment script before you deploy, change the deploy action of your project to Create a deployment script (.sql), and generate your deployment script. For more information, see How to: Deploy Changes to New or Existing Databases. Review the deployment script. If it is the version that you want, change the deployment action back to Create a deployment script (.sql) and deploy to the database, or you can run the script in the Transact-SQL editor with batch mode enabled.

  3. Deploy your changes to your isolated development environment. For more information, see How to: Deploy Changes to New or Existing Databases.

  4. Run the unit tests that match the version of your project against your isolated development environment.

  5. If you must modify an older version of a database, you should consider using the branching features that are available in Team Foundation version control. For more information, see Branching and Merging.

  6. If you want to deploy the database project to a production database, you can hand off the generated .dbschema file or deployment script to the team member who has access to the production server. That team member can review the script and then run it to deploy your changes into production.

See Also

Tasks

Add Files to Version Control

Concepts

An Overview of Database and Server Projects

Starting Team Database Development

Other Resources

Moving from Another Version Control System to Team Edition for Database Professionals