Undo changes

dbForge Source Control helps undo the database changes made in object and static data that were made in the database linked to the remote repository but have not been committed yet.

Note

The Undo operation leads to permanent changes in the database linked to a version control repository. These changes can be restored only from the database backup if the database was backed up before you applied the Undo operation.

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 Object Explorer:

Source Control label

Note

It is important to link static data to source control to prevent any data loss when updating your local database with the latest changes from the remote repository or reverting database changes made to the object and static data in a database.

dbForge Source Control checks if any changes have been made to the database locally or remotely and verifies if they have been committed to the repository. In the same way, dbForge Source Control checks if any changes have been committed to the version control and if they have been deployed to the linked database.

In addition, the tool identifies conflicts that may occur if multiple developers are making changes to the same file in the repository and the local database.

The Refresh progress window opens automatically, showing the stages of the refresh operation.

Refresh

After the refresh operation is complete, Source Control Manager opens, displaying all the changes in the following sections:

It should be noted that Source Control Manager can display all three sections or two of them, or just one section.

The tool distributes the changes in the following sections

Note

Local changes section

  • The Add change type indicates that the object was created locally in the database that is being version-controlled using Source Control and 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 being version-controlled using Source Control but is still present in the remote repository. Selecting the object and clicking Undo will restore it in the local database.
  • The Modify change type indicates that changes were made to the object in the local database that is being 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 and is not present 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 is present 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:

The database and version control repository are identical

To roll back the changes made to the database since the latest commit:

In the Local changes section, select the checkboxes next to the objects and/or static data you want to undo and then click Undo.

Note

If you select the checkbox next to Local changes, all changes will be selected.

Undoing changes

As you can see in the screenshot above, the Source Control grid contains the following columns:

Column Description
Change Type For Undo:
Actions to be applied to the object (but not to static data) in the linked database; these include the following action for database objects: Add (the object will be dropped); Modify (the object will be altered); Remove (the object will be created).

For Commit:
Actions to be applied to the object or static data in the source control repository. They include Add (the object or data will be added); Modify (the object or data will be modified); Remove (the object or data will be removed). For more information about how to commit changes, see Committing changes.
Type The type of the object; a Static Data is a table’s data type
Name The name of the object that will undergo changes; a <name> (Data) construction refers to static data
Owner The 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 Undo will display a window with a suggestion to include all related objects:

Dependencies window

This case may occur when you add, for example, two new database objects such as a table and a view, which select data from this new table. So, when you choose to deploy remote changes made only to the new view, you will be suggested to deploy the table associated with this view. In addition, you can exclude any related object from the deployment.

After clicking Undo, the tool asks whether you want to proceed:

Undo message

After confirming the Undo operation, the Undo progress window opens showing the stages of the undo operation. When all the stages are complete, click OK to close the progress window.

Undo results

The Undo operation runs the deployment script generated by dbForge 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.

So, local changes made in a database and have not been committed yet to a version control repository have successfully been undone to the database with the help of dbForge Source Control.

Note

You cannot undo the following database changes:

  • Committed changes
  • Static data changes (a data link or a data edit cannot undergo an Undo operation. To unlink a specific table, refer to Link static data)
  • Dropped data (dropped columns and tables cannot be restored with the Undo operation)
  • NOT NULL columns (dropped NOT NULL columns with data cannot be restored with the Undo operation unless the columns have default values)

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Source Control for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Source Control in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Source Control for your business, request a demo to see it in action.
Ready to start using dbForge Source Control for SQL Server?