dbForge Studio for SQL Server helps update your version control repository by committing changes made in a database. You can manage the changes in the Source Control Manager.
Before you can use the Source Control Manager, you must link a database to the version control repository by following the steps outlined in the relevant how-to topic:
The linked database gets the following icon in Database Explorer:
The Source Control tool checks if any changes were made to the database, locally or remotely, and if these changes were committed to the repository. In the same way, the tool checks whether any changes were committed to the version control and whether these changes were deployed to the linked database.
In addition, the Source Control tool scans for conflicts that may occur when multiple developers change the same file both in the repository and in the local database.
The Refresh progress window opens automatically, showing the stages of the refresh operation.
After the refresh operation is complete, the Source Control Manager opens, displaying all the changes in the following sections:
It is important to note that the Source Control Manager can display all three sections, two of them, or just one section.
Note
Local changes section
- The Add change type indicates that the object was created locally in the database that is version-controlled using Source Control but has not been committed to the remote repository yet. Selecting the object and clicking Undo will remove it from the local database.
- The Remove change type means that the object was deleted from the local database that is version-controlled using Source Control, but it still exists in the remote repository. Selecting the object and clicking Undo will restore it in the local database.
- The Modify change type signifies that changes were made to the object in the local database that is version-controlled using Source Control. As a result, the object’s DDL in the local database differs from the version stored in the remote repository. Selecting the object and clicking Undo will discard the changes made to the object in the local database, reverting it to the version from the repository.
Remote changes section
- The Add change type indicates that the object has been added to the remote repository since the last synchronization, but it does not exist in the local database that is linked to this repository via Source Control. Clicking Get Latest will add the object to the local database.
- The Remove change type means that the object has been removed from the remote repository since the last synchronization, but it exists in the local database that is linked to this repository via Source Control. Clicking Get Latest will remove the object from the local database.
- The Modify change type indicates that the object has been modified in the remote repository since the last synchronization. As a result, the object’s DDL in the repository differs from the version stored in the local database that is linked to this repository via Source Control. Clicking Get Latest will update the object in the local database to match the version from the repository.
If the database and version control repository are identical and no changes are found, the following window is displayed:
In the Local changes section, select the checkboxes next to the objects and/or static data you want to commit, enter the comment describing your commit, and click Commit. When you view the history of changes, these comments will help you understand the reasons behind each commit.
Note
If you select the checkbox next to Local changes, all changes will be selected.
Note
The Commit comment text box is unavailable when a database is linked to a working folder.
As you can see in the screenshot above, the Source Control grid contains the following columns:
Column | Description |
---|---|
Change Type | For Commit: Actions to be applied to the object or static data in the source control repository; these include Add (the object or data will be added), Modify (the object or data will be modified), and Remove (the object or data will be removed). For Undo: Actions to be applied to the object (but not to static data) in the linked database; these include the following actions for database objects: Add (the object will be dropped), Modify (the object will be altered), and Remove (the object will be created). For more information about how to undo changes, see Undo changes |
Type | Type of the object. Static Data is a table’s data type |
Name | Name of the object that will undergo changes. A <name> (Data) construction refers to static data |
Owner | Schema or database in which the object was created |
If you select an object that depends on other objects or changes in the Local changes section, clicking Commit will display a window with a suggestion to include all related objects:
This case may occur when you add two new database objects, such as a table and a view, which selects data from this new table. So, when you choose to commit only the new view, you will be suggested to commit the table associated with this view. In addition, you can exclude any related object from the commit.
After clicking Commit, the Commit progress window opens, showing the stages of the commit operation. When all the stages are complete, click OK to close the window.
The Commit operation runs the deployment script generated by the Source Control against the linked database to update it with the latest version of the database stored in the remote repository. The script contains CREATE, ALTER, and/or DROP statements for the database objects selected in the Source Control Manager, as well as INSERT, UPDATE, and/or DELETE statements for the changes to static data and the statuses (Remove, Modify, Add) of the objects.