Database Migration

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Most systems that need replacing are attached to a database that cannot be switched off. The legacy application keeps writing to it while the new system is built, tested and rolled out one capability at a time, so for weeks or months two databases hold overlapping data and both must stay correct. This section explains how to do that with Debezium, the open source change data capture (CDC) platform. Debezium reads the legacy database’s own transaction log, turns every committed insert, update and delete into an event, and publishes the events to a broker (Apache Kafka by default). Those events are then used to listen to the legacy system: to fill and maintain the new database, to feed new services, to verify that both sides agree and, after the cut-over, to keep the legacy side current in the other direction until it can be retired.

The architecture pages of this site already explain why log-based CDC is the safer way to keep a legacy and a new database in sync:

This section explains how: every concept of the official Debezium documentation, applied to the job of generating change events from a legacy database, listening to them and using them to migrate the data.

The content was checked on 2026-11-09 against Debezium 3.7.1.Final, the current stable release.

Version baseline

Component Version used in this section (checked 2026-11-09)

Debezium

3.7.1.Final (released 2026-11-06). 3.8 is in development (3.8.0.Alpha1); it is mentioned only as upcoming.

Java

17 or later for the connectors; 21 or later for Debezium Server, the Debezium Operator and the Quarkus extensions.

Kafka and Kafka Connect

Kafka 4.x in KRaft mode, as shipped in the quay.io/debezium/kafka:3.7.1.Final and quay.io/debezium/connect:3.7.1.Final images; Debezium supports Kafka Connect 3.1 and later.

Databases

Oracle AI Database 26ai Free, image gvenzl/oracle-free:23.26.3 (legacy source), PostgreSQL 18 (new database), MongoDB 8.0; the full list of tested versions is on the Debezium 3.7 release page.

Applications

Spring Boot 4.1 with Spring for Apache Kafka 4.1 on Java 21.

What’s covered

Introduction

  • Migration Strategies — big bang, dual writes, batch ETL, triggers, query-based and log-based CDC compared.

  • Migration Patterns with CDC — the phases of a CDC-driven migration, the strangler fig at the data layer, the anti-corruption layer as a stream translator.

Debezium fundamentals

Change events

Source connectors

Snapshots and signals

Transformations

Listening to events and applying them

Schema changes and the migration runbook

Operations

Wrap-up

Reading path

Pick the path that matches what you need:

  • PostgreSQL Reference — the target engine of the worked Oracle to PostgreSQL migration: logical replication, COPY, roles, and verification queries.

  • MySQL Reference — binary log, GTIDs and replication, the source side of MySQL change data capture.

Bibliography

Every source used to write this section, each linked to its official website. Each page lists the sources it used under its own References heading. Links were checked on 2026-11-09; every page returned HTTP 200 except the MySQL reference manual pages on dev.mysql.com, which refuse automated clients (HTTP 403) but open normally in a browser.

Debezium reference documentation

Debezium project, releases, blog and repositories

Apache Kafka, Kafka Connect and the Kafka ecosystem

Databases

Cloud providers

Frameworks, libraries and tools

Running example: Bookshop

The pages use the same Bookshop system as the architecture pages. The legacy application is a Java EE / Struts monolith on a single Oracle schema, BOOKSHOP. The new application is a Spring Boot 4.1 application, bookshop, on PostgreSQL 18, with a different model. The local examples run Oracle AI Database 26ai Free (container image gvenzl/oracle-free:23.26.3).

Concept Legacy Oracle (BOOKSHOP schema) New PostgreSQL (bookshop database)

Books

BOOK with NUMBER(10) key, a single AUTHOR_ID, ACTIVE_FLG CHAR(1) ('Y'/'N'), PUBLISHED DATE, LAST_UPD DATE

book with bigint key, active boolean, published_on date, updated_at timestamptz, plus book_author for several authors per book

Authors

AUTHOR (AUTHOR_ID, FULL_NAME)

author (id, full_name)

Customers

CUSTOMER with STATUS_CD CHAR(1) ('A'/'I') and CREATED_DT DATE

customer with a uuid key, legacy_id, status (ACTIVE/INACTIVE) and created_at timestamptz

Orders

ORDERS (STATUS_CD 'NW', 'PD', 'SH', 'CN') and ORDER_LINE (ORDER_ID, LINE_NO)

purchase_order (NEW, PAID, SHIPPED, CANCELLED, uuid key, legacy_id) and order_line

Supplier feed

SUPPLIER_CATALOGUE (SUPPLIER_ID, ISBN, SUPPLIER_PRICE, FEED_TS)

legacy_supplier_catalogue, a 1:1 mirror

The pipeline built across the section is as follows:

  • The bookshop-oracle-source connector (topic prefix legacy) streams the changes of the legacy schema to topics such as legacy.BOOKSHOP.BOOK.

  • The bookshop-pg-mirror-sink JDBC sink connector copies the tables that keep their shape into legacy_* mirror tables.

  • Consumers in the new application (LegacyBookTranslator, LegacyCustomerTranslator and LegacyOrderProjector) act as the anti-corruption layer that translates the legacy rows into the new model.

  • After the cut-over, the bookshop-pg-source connector (topic prefix modern) and the bookshop-oracle-reverse-sink connector replicate changes back to Oracle, so that a rollback stays possible.

A smaller MongoDB example (bookshop.reviews to a PostgreSQL book_review table) covers the cases where one side is a document database and the other is relational.

The migration pipeline: the legacy application writes to Oracle, Debezium reads the redo log and publishes change events to Kafka, a JDBC sink and the new application’s consumers apply them to PostgreSQL, and a strangler proxy routes users to the legacy or the new application