---
title: "CDC Sink: Overview"
description: "An introduction to CDC Sink, the RavenDB ongoing task that reads Change Data Capture streams from a relational database and writes documents into RavenDB."
url: "https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/overview"
version: "7.2"
---

# CDC Sink: Overview

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - **CDC Sink** is a RavenDB ongoing task that reads **Change Data Capture (CDC) streams** from a relational database  
>   and writes the resulting documents into RavenDB.
>
> - CDC Sink is the reverse of SQL ETL:  
>   instead of pushing data *from* RavenDB *to* a relational database,  
>   CDC Sink *pulls* data *from* the relational database *into* RavenDB.
>
> - The relational database remains the source of truth,  
>   while the CDC Sink task continuously maps normalized relational tables into RavenDB documents.
>
> - Supported source databases:
>   - **PostgreSQL** - via logical replication
>   - **SQL Server** - via native CDC (polling change tables)
>   - **MySQL / MariaDB** - via binlog replication
>
> - In this article:
>   - [Why use CDC Sink](#why-use-cdc-sink)
>   - [How it works](#how-it-works)
>   - [Task lifecycle](#task-lifecycle)
>   - [Licensing](#licensing)

## Why use CDC Sink {#why-use-cdc-sink}

CDC Sink solves the problem of moving data from a relational database into RavenDB without changing the source application.

- **Migrate from SQL to RavenDB**  
  Automatically and continuously transform normalized relational tables into RavenDB documents,  
  such as an *Order* document that embeds *LineItems* and references a *Customer* document,  
  without changing your application.

- **Build a read-optimized view**  
  Your transactional system uses a relational database, but your API layer needs denormalized documents.  
  CDC Sink creates and maintains those documents without touching your existing application.

- **Gradual migration**  
  Keep your existing application running while RavenDB documents are built in the background.  
  Applications can start reading from RavenDB while writes still go to the relational database.

- **Event-driven side effects**  
  Using JavaScript patches, every INSERT, UPDATE, or DELETE in the source database can trigger custom logic in RavenDB -
  computing derived fields, maintaining running totals, or writing custom transformations.

## How it works {#how-it-works}

A CDC Sink task continuously reads changes from the source relational database and applies them to RavenDB documents.

### Initial load

By default, when a CDC Sink task starts for the first time, it performs a full scan of every configured table using keyset pagination.
This populates RavenDB with the current state of the data before streaming begins.

The task can also be configured to skip the full scan and start from new CDC changes only, without scanning existing rows -
useful when you only need to capture changes going forward.

Initial load progress is persisted per-table.  
If the task is restarted, it resumes from where it left off rather than re-scanning.

### Streaming changes

After the initial load, CDC Sink switches to streaming changes continuously.  
Changes are grouped into transactions, preserving the exact order of operations from the source database.  
Partial transactions are never written to RavenDB - all changes within a source database transaction are applied together.

### Document model

The relational model is mapped to RavenDB documents through configuration:

- **Root tables** map to RavenDB collections (one document per row)
- **Embedded tables** become nested arrays or objects within parent documents
- **Linked tables** become document ID references to *related documents*

See [Schema design](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/document-modeling/schema-design.md) for details.

## Task lifecycle {#task-lifecycle}

1. **Create**  
   Define the CDC Sink task in Studio or via the Client API.  
   Specify the connection string, table mappings, and transformation options.  
   See [Create a CDC Sink task](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md).
   You can later [Update](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/update-task.md) or
   [Enable/Disable](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/enable-disable-task.md) the task.

   Before saving, you can verify the configuration against the live source database via Studio or the REST API,  
   see [Verify tables](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md#verify-tables).

2. **Verify**  
   When the task starts, CDC Sink verifies that the source database is properly configured,  
   including permissions, replication prerequisites, and table configuration.

3. **Initial load**  
   Full table scan populates RavenDB with current data.  
   Progress is tracked per table and persists across restarts.

4. **Stream**  
   Continuous change streaming begins.  
   All INSERTs, UPDATEs, and DELETEs are applied to RavenDB documents as they occur.

5. **Monitor**  
   [Monitor the task state](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/monitoring.md),
   or [Get task info](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/get-task-info.md) via Studio or via the Client API.

6. **Retire**  
   Delete the task in RavenDB when no longer needed.  
   Retiring a task removes it on the **RavenDB** side only.

   Change-tracking artifacts created in the source database (such as a PostgreSQL replication slot and publication)  
   are **not** removed automatically and must be cleaned up by the source-database administrator.  
   Learn more in [Delete a CDC Sink task](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/delete-task.md).

## Licensing {#licensing}

> **Info**
>
> CDC Sink is available on an **Enterprise** license.

Learn more about licensing in [Licensing overview](https://docs.ravendb.net/7.2/licensing/overview.md).

## See also

- [Create a Task](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md)
- [How It Works](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/how-it-works.md)
- [Schema Design](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/document-modeling/schema-design.md)
- [Configuration Reference](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/configuration-reference.md)
- [PostgreSQL Prerequisites Checklist](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/prerequisites-checklist.md)
- [PostgreSQL Initial Setup](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/postgres/initial-setup.md)
- [ETL Basics](https://docs.ravendb.net/7.2/server/ongoing-tasks/etl/basics.md)
- [Queue Sink Overview](https://docs.ravendb.net/7.2/server/ongoing-tasks/queue-sink/overview.md)
