dbForge Source Control helps to undo the database changes made in object and/or static data that were made in the database linked to the remote repository but have not been committed yet.
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.
To start working with Source Control Manager, first, you need to link a database to the version control repository. To do that, follow the steps in the how-to topics depending on the source control or version control systems you use:
The linked database gets the following icon in Object Explorer:
After the database has been linked to the remote repository, dbForge Source Control checks whether any changes were made to the database locally or remotely and committed to the repository. In addition, the tool checks if there are any conflicts meaning that several developers were making changes to the same file both in the repository and in the database.
The Refresh progress window opens automatically, showing the stages of the refresh operation.
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 either all three sections or two of them or just one section.
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 that you want to undo and then click Undo.
If you select the checkbox next to Local changes, all changes will be selected.
As you can see in the screenshot above, the Source Control grid contains the following columns:
|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); Remove (the object or data will be removed). For more information about how to commit changes, see Committing changes.
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)
|Type||The type of the object|
|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 not all objects in the Local Changes section but only one that depends on other objects or changes, then after clicking Undo, you will see the following window with the suggestion to include all affected objects:
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 Undo progress window opens, showing the stages of the undo operation. When all the stages are complete, click OK to close the progress window.
The Undo operation executes the deployment script generated by dbForge Source Control against the linked database to the remote repository. The script includes the CREATE, ALTER, and/or DROP statements based on the database objects selected in Source Control Manager as well as INSERT, UPDATE, and/or DELETE statements for the static data changes and on the statuses (Remove, Modify, Add) that the objects had.
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.
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)