Version-control database changes
Last modified: March 28, 2025
The Source Control tool built into dbForge Studio for MySQL is a version control tool to manage and track changes in MySQL and MariaDB databases. Its intuitive interface simplifies the handling of schema and data changes, which makes it easier to control database versions over time. The tool supports popular version control systems, such as Git, SVN, TFS, Perforce, etc. that allow for easier integration with your existing workflows. It also lets users compare database schemas and data in different versions and helps identify discrepancies and synchronize changes.
Method 1: Using a database project
Database Project helps organize and manage your database schema and related scripts in a structured project environment. It allows deploying and synchronizing database changes between different environments, such as development, testing, and production. The flow of change management typically looks like this:
1. Build the project: This step generates a deployment script that reflects all project changes. This script will be used to apply the updates to a testing database.
2. Deploy to the testing environment: This step involves deploying the generated script to the testing environment. Manually verify that all schema changes are applied correctly and confirm that the new schema doesn’t cause issues with existing data or functionality.
3. Commit and push: After you’ve validated that the changes work as expected, commit and push them to your version control repository using the Git appropriate commands from the command line. If you work in a team, this might include opening a pull request for code review.
Method 2: Using a scripts folder
If you do not want to use the database project, you can manage database changes using a scripts folder and then commit the updates to a repository using a third-party version control tool.
Similarly to a database project, a scripts folder is a directory structure where SQL database-related scripts are stored and organized. It allows you to group and organize your database scripts in folders, which enables easy navigation and access to the SQL files that represent your database objects and queries.
Here are the steps involved in managing changes within a scripts folder using a third-party version control tool:
1. Create a scripts folder in your project for SQL scripts, for example, scripts/
and organize the folder with subdirectories for different types of scripts, such as scripts/migrations/
for migration scripts and scripts/procedures/
for stored procedures.
2. Modify SQL scripts in your preferred SQL editor or IDE, such as dbForge Studio, and save them to the appropriate folders within the scripts folder.
3. Before committing the changes, run the scripts locally on your testing database to verify they work as expected.
4. Open your version control tool, such as Git, from the command line or GUI.
5. Commit the changes using the appropriate command and then push them to the remote repository.
6. If you work in a team, create a pull request for others to review your changes. If it is approved, merge it with the main branch. If team members make changes and push them to the repository, you’ll need to fetch or pull those changes to keep your local repository updated.
7. After the changes are finalized and merged, deploy the updated scripts to the testing or production database.
Method 3: Using a scripts folder along with dbForge Source Control
You can link a scripts folder to a version-control system, such as Git, SVN, TFS, or Perforce. This allows you to track changes to each script in the folder. As developers update the database schema, for example, creating tables or modifying stored procedures, they can save the corresponding SQL scripts to the scripts folder. Using the version control system, these changes can be monitored and managed over time. By storing all SQL scripts in a scripts folder and committing them to source control, you can monitor the history of changes for each database object.
In addition, the scripts folder allows for easy synchronization of database changes between different environments, such as development, testing, or production. You can pull the latest changes from source control, apply them to the database, and ensure consistency across all environments.
If you prefer to use a database project based on a scripts folder and deploy the generated scripts to your version control system, start by creating a dedicated folder for SQL scripts within your project. After making any necessary changes, link the database to this working folder. You can establish the connection between the database and the working folder using dbForge Source Control for MySQL available in dbForge Studio. For more information, see How to link a database to a working folder.
After you commit the required changes to the working folder, you can source-control the database working folder with the third-party version control GUI client in the same way you version-control other files.
Method 4: Using dbForge Source Control for MySQL
The easiest way to manage changes is by directly linking your database to your preferred source control system. The tool saves you significant time and effort. Unlike the previous methods that involve multiple intermediate steps to deploy the changes to the repository using a third-party tool, dbForge Source Control allows you to link your databases directly to your source control. You can make changes and commit them to the remote repository, all within a single tool.
Let us focus your attention on why dbForge Source Control is the superior choice:
- Version Control: Supporting popular version control systems, for example Git, SVN, TFS, etc., allowing you to monitor database changes, manage versions, and roll back changes when needed.
- History of changes: Tracking the history of database schema and data changes, and viewing and comparing different versions of objects.
- Synchronization and deployment: Synchronizing changes between different versions of the database and deploying changes across various environments, such as development, testing, or production.
- Collaboration: Enabling multiple developers to work on the same database simultaneously or manage conflicts.
- CI/CD Integration: Integrating with continuous integration and deployment (CI/CD) systems, facilitating automation of database deployment and testing.
- All-in-one: Version-controlling schemas and static data, modifying the databases, committing or undoing changes, getting the latest changes from the repository, and resolving conflicts (if any) within a single IDE.
For more information about how to link a database to a Git repository, see Link a database to source control.
As you can see, a lot of tools are available for deploying database changes. However, dbForge Source Control for MySQL stands out as a leader due to its simplicity, user-friendly interface, and the capability to manage database version control all within a single IDE.
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for MySQL.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.