Database Migration Without Downtime

Published
Length
3 min read

Luis Felipe Dias

All posts

You run a database migration without downtime by syncing live changes to a new target. Once both stores match, you switch app traffic over without stopping writes. Teams often grant broad admin roles to engineers during this move. Those wide roles let people run risky commands on live tables by mistake. How a database migration without downtime works A zero-downtime move splits the work into four safe phases. First, you set up the new database alongside the old one. Your current app keeps rea

Database Access Proxy + Post-Quantum Migration Planning: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You run a database migration without downtime by syncing live changes to a new target. Once both stores match, you switch app traffic over without stopping writes. Teams often grant broad admin roles to engineers during this move. Those wide roles let people run risky commands on live tables by mistake.

How a database migration without downtime works

A zero-downtime move splits the work into four safe phases. First, you set up the new database alongside the old one. Your current app keeps reading and writing to the old system as normal. Nothing changes for your users during this first step.

Second, you take a full snapshot of the source data. You load this base copy into the new target database. While that copy runs, new writes still hit the source tables. You track those new changes using a change data capture stream.

Third, the sync tool replays every new write onto the target database. Soon, the new store catches up to the live source store. Teams then run read checks to compare rows across both systems. You must confirm that row counts and key values match.

Fourth, you shift app reads and writes to the new database. You keep a backward sync stream open for a short time. If the new database fails, you point the app back to the old one. Once the new system runs well, you shut down the old database.

How to handle schema changes during the move

Moving data is harder when you also change table structures. You should use the expand and contract pattern for schema updates. First, you add new columns or tables without dropping old ones. Both old and new app code can run against this expanded schema.

Next, you update the app so it writes to both old and new columns. A background job fills in missing data for older rows. When all rows have the new format, you switch reads to the new columns. Last, you remove the old columns after the cutover finishes.

Database Access Proxy + Post-Quantum Migration Planning: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native migration setups solve and what they miss

Native replication tools and cloud transfer services move rows fast. They keep source and target systems in sync over the network. Database roles also let you control which user accounts can log in. These built-in tools solve the core data copy problem.

Still, native roles leave a big gap during the cutover window. Standard permissions only check who logs in to the database. They do not inspect what individual queries or commands do in flight. An engineer who logs in to check row counts often has full write rights.

During a tense cutover, one wrong command can drop a table or lock rows. Also, engineers running manual checks see raw emails, phone numbers, and card numbers. Native database roles cannot rewrite those sensitive fields in query results on the fly. Teams need a way to approve risky statements and mask fields during live checks.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

How do you roll back if the new database fails after cutover?

You keep reverse replication running from the new database back to the old one. If errors spike, you point your app back to the original database right away.

How do you check that source and target data match before switching?

You run read queries that compare row counts and hashes across both databases. Doing this on small batches avoids heavy locks on live tables.

Why should you avoid schema locks during a live data move?

A table lock blocks incoming app writes and causes an immediate outage. Breaking changes into small steps keeps tables open for live traffic.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.