What is a database migration?

Database migration involves moving the data contained in the database, including schema objects (tables, indexes, views), stored procedures, functions, and triggers, from an existing database to a new or updated database.

Learn about Database Migration Service and migrate your database to Google Cloud.

How does database migration differ from data migration?

Data migration is a component of the database migration process that moves data from one environment to another. You may need to move your data without migrating your database, such as in the case of making storage-related changes.

The key to successful data and database migration is to transfer your information accurately and quickly, while minimizing downtime and disruption during the transfer and during the cutover.

Why migrate your database?

Sometimes, you don't migrate because you want to, you migrate because you have to. Legacy systems can eventually reach a point where they can no longer keep up with the demands of a modern business, and maintaining them might become a risk rather than an asset.

Here are some key reasons you might need a database migration:

  • End-of-life hardware: Your physical servers are aging, and the manufacturer no longer supports the hardware or the operating system
  • Performance bottlenecks: Your current database architecture can’t handle your data volume or traffic spikes, causing slow experiences for your users
  • Security and compliance: Legacy systems may lack the modern security features, patches, or auditing capabilities required to meet today’s regulatory standards
  • Vendor lock-in: You’re tied to a proprietary, expensive, or inflexible license that limits your ability to innovate or choose the best tools for your specific needs
  • Data silos: Your data is trapped in isolated, on-premises systems, making it difficult to feed into modern analytics or AI models that your team needs to stay competitive

When your existing architecture can no longer support your operational requirements, migration is the necessary next step to keep your business running securely and efficiently.

Homogeneous versus heterogeneous migrations

When you move your database, you’ll likely hear the terms homogeneous and heterogeneous. Understanding the difference helps you plan how much work your technical team needs to do.

Migration type

What it means

How it works

Homogeneous

The source and target databases use the same or very similar engine.

This is usually simpler because the data formats are already compatible.

Heterogeneous

The target database uses a different engine than your source.

This requires converting your schema and code so the new database understands them.

Migration type

What it means

How it works

Homogeneous

The source and target databases use the same or very similar engine.

This is usually simpler because the data formats are already compatible.

Heterogeneous

The target database uses a different engine than your source.

This requires converting your schema and code so the new database understands them.

Data migration strategies

There are four common strategies for migrating data. Visit cloud migration strategies for a deep dive and recommended strategies.

  • Rehost: lift and shift. The simplest way to migrate your data, this makes a complete copy of your existing database into another environment, usually together with the rest of the application stack. [homogeneous]
  • Replatform: lift and optimize. This strategy copies the databases, applications and virtual machines and then optimizes them for the new cloud environment. This can be a heterogeneous migration, such as when moving from a commercial database to a PostgreSQL-compatible database such as AlloyDB. [homogeneous/heterogeneous]
  • Refactor: move and improve. A refactoring cloud migration strategy involves re-engineering applications to align with cloud-native principles, requiring changes to the application code itself. [usually heterogeneous]
  • Rebuild. A rebuilding cloud migration strategy rewrites an architecture and application entirely for the cloud. Depending on your application, this can be cheaper than refactoring. [usually heterogeneous]

Database migration FAQs

Yes, and it’s becoming a common way to speed up the process. AI, and LLMs in particular, can help analyze your existing code and schema to suggest conversions for your target database. This helps automate complex code rewrites and can catch compatibility issues that might otherwise cause delays during your migration.

It can take anywhere from a few days to several months, so it’s important to plan. Factors include the size of your database (small projects might take a few days, while complex, multi-layered migrations can take several months), your migration strategy, and whether you’re using a database migration service.

A schema is the blueprint or map of your database. It defines how your data is organized, including tables, fields, and how they relate to one another. During a migration, you may need to convert this blueprint if you are moving to a different type of database engine.

The biggest risks include data loss, long periods of downtime, and security gaps. If the migration isn't planned well, your applications might not work correctly in the new environment. Using a managed migration service and testing your system thoroughly helps reduce these risks.

You can often minimize downtime by using replication, where your old and new databases run at the same time. While some brief downtime is usually necessary during the final "cutover" phase, advanced migration services are designed to make this window as short as possible.

Benefits of using a database migration service

Database migration is more than just moving the data, it’s preserving the functions so that your workloads run without a hitch on your new system. How you migrate will depend on the code you’ve written and your migration tools. 

Moving data manually can be risky and time-consuming, but using a dedicated migration service can help keep your project on track. 

Faster transfers

Specialized tools use optimized paths to move your data quickly.

Less downtime

Migration services help keep your applications running so your customers don't notice a service gap.

Data consistency

These tools ensure your data looks and acts the same in the new system as it did in the old one.

Security

Your data is encrypted while it moves, which keeps it safe from prying eyes.

Simplified complexity

If you are moving to a different database engine, these services can often help convert your code automatically.

Lower costs

By reducing manual work and shortening the project timeline, you save on labor and overhead.

Benefits of migrating to the cloud

While you can migrate your database between virtually any two locations, the majority of migrations are either from on-premises to cloud or from one cloud to another.

There are many reasons why companies are migrating to the cloud (or to an alternate cloud provider):

  • Faster application development
  • Improved performance and scalability 
  • Cost savings
  • Security
  • A wider range of features, in particular AI-related ones
  • A shift from an on-premises capital expenditure (CapEx), common with traditional licensed databases, to operating expenditure (OpEx), common with cloud service

Learn more about the benefits of migrating to the cloud.

Special considerations for migrating from on-premises to cloud

Many organizations are moving their on-premises workloads to the cloud for the reasons discussed above. Migrations from on-premises require additional considerations compared to cloud-to-cloud migrations.

A common strategy to migrate on-premises workloads is rehosting, which copies your entire workload over to the cloud. Doing this reaps the security, reliability, and some cost benefits associated with cloud migration. 

Something to note, however, is that this strategy can also transfer any existing inefficiencies from the on-premises architecture over to the cloud infrastructure, which can cause you to miss out on the larger cost savings and efficiencies associated with a cloud-native architecture. You may also miss the rich functionality of the cloud in areas like disaster recovery, analytics integration, AI/ML services, and a marketplace of partner offerings.

Make sure to maintain the security of your data during the migration, particularly between different types of environments. One way to ensure the best security is to use a trusted database migration service.

Data migration best practices

Data and database migrations can be complex. It is essential to ensure that your enterprise’s data, as well as its organization and functions, move to the new architecture seamlessly. If done improperly, you may experience data loss, workloads not running properly, or security issues.

Some best practices:

  • Understand your data. It’s essential to know what your needs are for your specific business case and application.
  • Evaluate where your business is heading. Taking scaling into consideration is key to choosing the right architecture and provider. 
  • Test with feature flags. Use feature flags to roll out your new database to a small group of users first. This lets you test the system safely before a full launch.
  • Select the right data migration strategy that makes sense for your situation.
  • Follow a data migration plan carefully to ensure optimum performance.

Steps for a successful migration

For an in-depth look into the process, read concepts and principles of data migration and setting up and executing the data migration process.

Although the details will vary based on your specific business case, these are the basic steps of a successful migration:

  1. Identify where all of your data currently is, what format it’s in, and where it should be post-migration. You may determine you don’t need to migrate all of it, and can archive or delete old data. This also is a key time to note any potential risks of migration.
  2. Plan your migration strategy. Determine which migration strategy will work best, decide whether downtime can happen during business hours, and set a budget. 
  3. Execute your migration. You may want to use a migration service for implementation.
  4. Test your new system before the cutover. This enables you to identify any workloads that aren’t working appropriately and resolve any issues. You may need to run both databases concurrently, requiring replication of data from one system to the other. Only once you have confirmed all workloads are operating on the new database as expected can you shut down your old system.

The number of phases your migration will take depends on your organization’s existing setup and timeline. For example, migrating from a self-managed, on-premises deployment to a managed cloud service can be accomplished in a single step. Or, if there is time pressure, you can first migrate to a self-managed database in the cloud, and then switch to a fully managed solution.

Key considerations for database migrations

Ideally, database migration isn’t a process your company will do often. To make the most of your migration, here are a few key questions to think about:

Consideration

Recommendation

Which databases and applications should you migrate first?


Start with lower-priority or internal workloads. This gives your team a chance to refine the process before touching mission-critical systems.

Should you change your data model?

Evaluate if your current model meets your needs. Switching to a different model, such as moving to a NoSQL database, can provide more flexibility if your data structure is changing.

Should you manage the database yourself or choose a managed service?

Opt for a managed service whenever possible. It offloads maintenance and patching, which lets your team focus on building applications rather than managing infrastructure.

How will migration interfere with business operations?

Plan for minimal disruption by using replication, which lets your old and new databases run at the same time until you're ready for the final cutover.

Consideration

Recommendation

Which databases and applications should you migrate first?


Start with lower-priority or internal workloads. This gives your team a chance to refine the process before touching mission-critical systems.

Should you change your data model?

Evaluate if your current model meets your needs. Switching to a different model, such as moving to a NoSQL database, can provide more flexibility if your data structure is changing.

Should you manage the database yourself or choose a managed service?

Opt for a managed service whenever possible. It offloads maintenance and patching, which lets your team focus on building applications rather than managing infrastructure.

How will migration interfere with business operations?

Plan for minimal disruption by using replication, which lets your old and new databases run at the same time until you're ready for the final cutover.

Take the next step

Start building on Google Cloud with $300 in free credits and 20+ always free products.

Google Cloud