How to undo changes

dbForge Studio for MySQL allows you to revert database changes made to the object and static data in a database linked to a remote repository, provided these changes have not yet been committed.

Note

The Undo operation leads to permanent changes in the database linked to a version control repository. These changes can be restored only from a database backup that was created before you executed the Undo operation.

To start using the Source Control tool, 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:

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.

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

In addition, the Source Control identifies conflicts that may occur if multiple developers were 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, the Source Control Manager opens displaying all the changes in the following sections:

It should be noted that the 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 actions for database objects: Add (the object will be dropped), Modify (the object will be altered), and Remove (the object will be created).

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 more information about how to commit changes, see Committing changes
Type The type of the object. 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 selects 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

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

The Undo 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.

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 Studio for MySQL.
All Features

All features

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

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for MySQL?