What is Database Schema Migration?

Candy6 min read
What is Database Schema Migration?

This is a series of articles about database schema change / database schema migration:

  1. What is a Database Schema?
  2. What is a Database Schema Migration? (this one)
  3. How to Handle Database Migration / Schema Change?
  4. Top Database Schema Change Tools in 2023

What is Database Schema Migration

Database schema migrations, also known as database migrations, schema migrations, or simply migrations, are the process of modifying the structure of objects within relational databases. Migrations enable the evolution of database schema from their current state to a new desired state, which may include adding views or tables, changing the type of fields, or defining constraints.

Take an example of adding a table, you can execute the following SQLs in a Terminal connected to MySQL server. By executing these commands, you will have successfully completed a database migration.

-- Add a table
CREATE TABLE `employee` (
  `id` int NOT NULL COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  PRIMARY KEY (`id`)

Two Types of Database Migration

There are two primary types of database migration:

  • Migration-based migration
  • State-based migration

Migration-Based Migration

Migration-based migration, also known as change-based migration, involves creating a series of scripts that modify the existing database schema in small increments until it reaches the desired end state. Each script contains a set of DDL statements such as CREATE/ALTER/DROP TABLE.

Migration-based migration offers the advantage of allowing for quick and iterative changes to the database schema. This makes it easier to modify larger and more complex database systems without having to learn the entire schema. You can simply create scripts to perform the necessary changes and apply them to the database. This generally makes the changes more lightweight and efficient.

However, it's worth noting that this approach also has its disadvantages. The entire state of the database schema at any point can be difficult to reason out after the initial point, which can lead to confusion or errors down the line. Furthermore, the order of executing scripts is crucial. If they are not executed in the correct sequence, the desired schema may not be achieved or the scripts may fail to apply to the database.

State-Based Migration

The alternative to migration-based migration is the state-based migration. The actual migration process is more complex than the migration-based approach. It involves producing scripts to describe the desired state of the entire database schema, generating files by comparing the created files against the database's current state, and then applying the generated files to the database to reach the desired state. The scripts of state-based migration are the same as the schema dump files generated by mysqldump or pg_dump.

State-based migration has the advantage of producing files that fully describe the database state at any point, which makes it suited for your database CI/CD workflows. However, you will need an experienced personnel to carefully review the generated files to prevent data loss For instance, when state-based migration renames a table by deleting the current one and recreating it with a new name, someone must recognize this and take action to prevent data loss.

Both the two schema transformation strategies are used to facilitate the process of modifying database schema. Depending on the development style of the team involved, one approach might be better suited for a particular project than the other. In some cases, it may be helpful to employ a combination of both for maximum efficiency. You can check out Database Version Control, State-based or Migration-based? to get more details.

As technology continues to evolve, there are a few primary trends in database migration:

Continuous Integration and Delivery (CI/CD)

There is a growing trend towards incorporating database schema migrations into the CI/CD workflow, enabling more frequent and seamless deployment of changes to production environments. With the CI/CD tools and platforms, DBA can easily roll out schema scripts to multiple databases with just a few clicks. This not only speeds up the migration process but also reduces the risk of human error and minimizes service downtime during migrations.

Team Collaboration

With the increasing popularity of DevOps among teams, the collaboration between application developers and DBA is becoming increasingly important and valued. In a DevOps team, application developers and DBAs work together throughout the development lifecycle, from planning to deployment. This approach breaks down silos and allows application developers and DBAs to share information and work together more effectively.

Data Governance and Compliance

As regulations on data privacy and security continue to evolve, it is becoming increasingly critical to ensure that database schema migrations adhere to these standards. This may require integrating data governance and compliance checks into the migration process, as well as implementing improved tools for auditing and reporting on schema changes.

Machine Learning and Artificial Intelligence (AI)

With the explosion of OpenAI, the potential of machine learning and AI in various fields and industries has become increasingly apparent. The database field is no exception to this trend. As Machine Mearning and AI are increasingly being utilized to improve database management and operations. For example, text2sql tools like sqlchat can leverage AI capabilities to make it easier for non-technical users to interact with databases. In the future, Machine Learning and AI technologies will play a crucial role in database schema migration, such as identifying potential issues, optimizing migration processes, and recommending schema improvements based on patterns and trends in data usage and performance.

In summary, the future of database schema migrations is likely to be featured by integration with CI/CD workflow, valued collaboration in teams, a focus on data governance and compliance, and the increasing use of machine learning and AI. These trends will help to ensure that schema migrations are more efficient, secure, compliant with evolving regulations, and intelligent.

All in One Database Migration Tool

Given the trends of database migration, we recommend the all-in-one database migration tool for you: Bytebase


Bytebase is an open-source database DevOps tool, covering database management scenarios from changes, queries, security, to governance with a GUI web-based collaboration workspace.

  • Visual workflow for database migration


Bytebase offers a visual workflow for database migration, allowing developers and DBAs to easily collaborate on the migration process through an intuitive UI.

  • Database-as-Code

Besides UI workflow, Bytebase integrates GitOps capabilities with code repositories such as GitLab, GitHub and Bitbucket. Application developers can submit database change files to familiar code repositories. Once the review is completed and committed to the repository, Bytebase will automatically trigger the database change deployment.

  • Team Collaboration


Bytebase provides different roles for members at two levels: Workspace and Project. You can assign different roles to your team members, enabling them to have different permissions for different projects.

  • AI-based index optimization advisor


Bytebase offers an index advisor based on OpenAI API, which analyzes the slow queries and recommends the indexes that can effectively speed up the slow queries.

For comparing among different database migration tools on the market, you can take a look at Top Database Schema Migration Tools in 2023 for more details.


In this post, we explore the definition and two types of database migration, as well as its development trends and show you how Bytebase is desgined with those trends in mind. If you are interested in learning more about this topic, refer to How to Handle Database Migration / Schema Change.

Jointhe community

At Bytebase, we believe in the power of collaboration and open communication, and we have a number of communities that you can join to connect with other like-minded.

Subscribe to Newsletter

By subscribing, you agree with Bytebase's Terms of Service and Privacy Policy.