How to resolve conflicts

A conflict arises when there’s a discrepancy between the latest version of an object in source control and the one in the local database. The most common reason of conflicts is that multiple people were modifying the same file simultaneously. dbForge Source Control helps resolve conflicts in the Source Control Manager.

The guide provides the following instructions:

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:

Source Control label

The Source Control tool checks if any changes were made to the database, either locally or remotely, and if these changes were committed to the repository. In the same way, it checks whether any changes were committed to the version control and whether these changes were deployed to the linked database.

In addition, the tool scans for conflicts that can occur when multiple developers are making changes to 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.

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 either 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 signifies 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 resolve a conflict

In the Conflicts section, select the checkboxes next to the conflicts you want to resolve.

Note

If you select the checkbox next to Conflicts, all conflicts will be selected.

The Conflict window

The Source Control grid contains the following columns:

Column Description
Change Type Actions to be applied to the object or static data. In this case, the single available change type is Conflict
Type Type of the object
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

Select the required way to resolve your conflict:

  • Get Local: Your version of the object/data will be committed to source control. The changes are then displayed in the Local changes section of the Source Control Manager and can be managed as described in Commit changes.
  • Get Remote: Your changes will be discarded. The local database will be updated with the latest version of the object/data from source control. The changes are then displayed in the Remote changes section of the Source Control Manager and can be managed as described in Get the latest version.

Conflicts with static data

Keep in mind that data changes may not apply without the related schema changes. If you have applied both schema and data changes to a database object, it is important to commit them together. Similarly, if you are pulling schema and data changes made by someone else, retrieve them simultaneously.

Therefore, if you have a schema conflict along with a data change for an object, the change cannot be committed or retrieved without resolving the schema conflict beforehand.

Let us showcase how to resolve conflicts using the Source Control tool available in dbForge Studio for MySQL.

Worked example: How to resolve a conflict

The image illustrates the workflow for resolving conflicts using dbForge Studio for MySQL.

Git conflict

Let’s walk through the steps to resolve a conflict using the provided example. Suppose two sample databases - sakiladev1 and sakiladev2 contain the same tables.

1. Link both databases to the same Git version control repository - sakila. After that, the Source Control Manager opens for each database, displaying the local changes, if any, or showing that the databases are identical.

2. The first developer (Dev1) modifies the actors table.

3. The second developer (Dev2) makes the different changes to the actors table and commits them to the repository:

4. Dev1 modifies the categories table, while Dev2 modifies the categories table differently and commits the changes to the repository.

5. Dev1 modifies the films table, while Dev2 modifies the films table differently and commits the changes to the repository.

6. Dev1 refreshes the Source Control Manager of the sakiladev1 database. Source Control detects the changes and displays them with the Conflict change type in the Conflicts section:

Conflict

8. Dev1 decides that changes in the actors and categories tables have been mistaken. So, Dev1 commits their local changes for these tables and overrides the changes made by Dev2. To do this, select the actors and categories tables and click Get Local.

Get Local Dev1

The tables are then displayed with the Modify change type in the Local changes section. In addition, Dev1 wants to get remote changes made to the films table by Dev2. To do this, select films and click Get Remote.

Get Remote Dev1

The table is then displayed with the Modify change type in the Remote changes section. Select the table and click Get Latest. For the actors and categories tables, click Commit.

Get Latest Dev1

Refresh the Source Control Manager; it will show no changes and determine databases as identical.

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?