How to Set Up Source Control: a Short Guide for Evaluators

July 30th, 2019

dbForge Source Control is a powerful SSMS add-in for managing SQL Server database changes in version control systems. The tool allows version-controlling schemas and reference data, rolling back changes, and maintaining the referential integrity of your SQL databases. This solution can also solve other database challenges, including deployment without losing data. dbForge Source Control can link your databases to all common source control systems, including SVN, TFVC, Git, Perforce, Mercurial, and SourceGear Vault. By any definition, dbForge Source Control delivers smooth and clear workflow in a familiar interface.

This guide is aimed at providing information about setting up and using the dbForge Source Control tool with your database and version control system, as well as getting started, committing and getting changes, and sharing options with the team. If you already own dbForge Source Control and need help getting set up, visit our documentation center to learn how to get started and how to use dbForge Source Control.

Linking your database to Source Control

To begin with, let’s take a look at how to link your database to your source control repository.

In Object Explorer, right-click a database you want to link to source control. Then, in the Source Control submenu select Link database to Source Control.

 

The Link Database to Source Control wizard opens. Now, on the Link tab of the wizard, click ‘+’ in the Source control repository field.

Next, in the Source Control Repository Properties dialog box that opens select the required source control system from the Source Control system drop-down list box. We’ll select Git in our example.

Other options you can choose include:

  • SVN
  • SourceGear Vault
  • Perforce(P4)
  • Mercurial
  • Working folder
  • Command Line Interaction

You can find detailed information about those options in our documentation center.

In our example, we’re linking our database to GIT. In this case, when setting Source control settings, you can use a remote repository or a local clone of a remote repository.

To link a database to a remote repository, specify:

  • URL of the Remote Repository.
  • If you connect via HTTP or SSH protocol, set up Security settings:
    • For the HTTP protocol, specify:
      • Login and Password for the remote Git repository.
      • Client Certificate, if the server is set up for authentication using the client certificate.
  • For the SSH protocol, specify the authentication method:
    • To authenticate with a password, select the Password option, and type your password in the corresponding box.
    • To authenticate with a key, select the Key option, and provide a path to the key file and passphrase in the corresponding boxes.
  • Branch.
  • Git User name and E-Mail.
  • Repository name.

If you have a ready local clone of the remote repository, you can use it instead of the technical clone created by dbForge Source Control. In this case, all settings (including the address of the remote repository) will be taken from the selected local clone.

To link a database to a local clone:

  • Select the Use existing local clone check-box and specify a path to it.
  • Select Branch from the drop-down list box.
  • Specify the Git User name and E-Mail.
  • Specify the Repository name.

In the end, click OK to close the Source Control Repository Properties dialog box. Then, select a database development model. For more information, refer to the Database Development Models topic in our documentation center. And finally, click Link. If a database is linked to source control successfully, a database icon in Object Explorer will be changed to show that a database is linked.

Making an initial commit

Now, when you’ve linked your database to source control, you can make your first commit. This will get a copy of your database into source control.

To make a commit, right-click a linked database in Object Explorer. Then, select Commit in the Source Control submenu.

Source Control Manager opens.

In the Local changes section of the document, select objects and/or static data you want to commit.

Next, in the text box, write a commit message (e.g . “First commit”), and click Commit.

The Commit dialog box showing all the stages of the commit operation opens. When all stages are complete, click OK to close the dialog box to complete the operation.

The Refresh window appears after that.

After closing the Commit and Refresh windows the changes are added to the repository.

Getting changes

To update your local version with the latest changes from source control, in Object Explorer, right-click a linked database you need to update. Then, click Get Latest in the Source Control submenu.

Source Control Manager opens.

 

Now, navigate to the Remote Changes section of the document, select objects and/or data you want to update. Next, click the Get Latest button. The Get Latest dialog box showing all the stages of the get latest operation opens. When all stages are complete, click OK to close the dialog box to complete the operation.

After closing the Refresh window your repository will be updated.

Setting dbForge Source Control options and sharing them with your team

You can configure dbForge Source Control to suit your development process. When you edit an option, it appears in the Commit changes tab as a change to commit. After you commit, other members of your team can get your change to the configurations performing the Get latest operation. This makes sure everyone works with the same options.

Let’s consider setting Linking static data to source control option.

First, you need to link data change tracking (static data) to the repository:

Then, choose the tables for data change tracking and click Link\Unlink.

Please note, that Static Data can only be linked to tables with Primary Keys.

Then the Refresh window appears and the Source Control Manager opens after that.
The Static Data objects appear in the Source Control Manager window in Local Changes:

Now, you need to select the objects and click Commit in order to send the data to the repository. After closing the Commit and Refresh windows the changes are added to the repository.

Sharing option changes with your team

If it is necessary for all your team to work with the same options, other team members can get the changes you’ve made to the options performing the Get latest operation.

 

Conclusion

dbForge Source Control comprises an advanced tool that links a database to the source control system, so that developers can share changes to reference data and schemas, check the history of database changes, and roll back anything they need, without leaving SQL Server Management Studio. dbForge Source Control unfailingly helps maintain the referential integrity of the database. If you want to try our solution you can download it from our site.

 

See also
  • No related posts
  • Leave a Comment