cdc

Installation
SKILL.md

CDC (Change Data Capture)

CDC is per connection: PRAGMA capture_data_changes_conn(...) makes each write also insert a row into a CDC table (default name turso_cdc).

Schema versions

  • v1 columns: change_id, change_time, change_type, table_name, id, before, after, updates.
  • v2 columns: change_id, change_time, change_txn_id, change_type, table_name, id, before, after, updates. v2 is the current version.
  • change_type is 1 (insert), 0 (update), -1 (delete), 2 (COMMIT record, v2 only).
  • The version of each CDC table is a row in the turso_cdc_version table (columns table_name, version).
  • When the pragma is enabled and the CDC table already exists without a version row, the version is set to v1. A new CDC table gets the requested version (v2 by default).
  • Writes to the CDC table and to turso_cdc_version are not captured.

COMMIT records (v2)

  • A statement running in autocommit mode ends by inserting one COMMIT record, and only when it captured something.
  • Only the root statement writes it. Trigger and foreign key action subprograms do not.
  • change_txn_id comes from the connection's CDC transaction id, which is reset to -1 after commit.

Pragma changes apply at Halt

Installs
154
GitHub Stars
25.3K
First Seen
Feb 17, 2026