Driftbase Docs

Configuration reference

A project is configured by one driftbase.toml file. drift looks for it in the current directory, or wherever --config / DRIFT_CONFIG points. Any string value can read from the environment with the env: prefix, for example api_key = "env:MEILI_MASTER_KEY".

Sources

[source.main]
url = "postgres://driftbase@db.internal:5432/shop"
slot = "driftbase_main"
publication = "driftbase_main"
KeyDefaultDescription
url(required)Connection string for a role with the REPLICATION attribute.
slotdriftbase_<name>Replication slot name. Created on first drift sync.
publicationdriftbase_<name>Publication name. Driftbase adds pipeline tables to it.
max_slot_mb10240Alert when retained WAL for the slot exceeds this size.
tls"prefer"disable, prefer, require or verify-full.

The source database must run with wal_level = logical, otherwise Driftbase cannot recieve changes and drift sync exits with E102: wal_level is replica.

Sinks

[sink.search]
type = "meilisearch"
url = "https://search.internal:7700"
api_key = "env:MEILI_MASTER_KEY"
batch_size = 500
KeyApplies toDescription
typeallelasticsearch, opensearch, meilisearch, typesense, redis, valkey
urlallEndpoint of the sink.
api_keysearch sinksAPI key with write access to the target index.
batch_sizesearch sinksDocuments per bulk request. Default 500.
key_prefixredis, valkeyPrepended to every key, for example "shop:".

Pipelines

Each [[pipeline]] block connects one source to one sink.

[[pipeline]]
source = "main"
sink = "search"
table = "products"
index = "products"
columns = ["id", "name", "price_cents", "updated_at"]
on_delete = "delete"
KeyDefaultDescription
table—Read one table as is. Use table or query, not both.
query—Shape documents with SQL. See below.
indextable nameIndex, collection or key pattern in the sink.
idprimary keyColumn used as the document ID.
columnsallOnly send these columns.
redactnoneColumns to drop ("drop") or hash ("sha256") before sending.
on_delete"delete"delete removes the document; soft sets _deleted: true instead.

Pipeline query

Use query to join tables and nest child rows. Driftbase finds every table the query reads and re-renders the affected parent documents when any of them changes.

[[pipeline]]
source = "main"
sink = "search"
index = "orders"
query = """
SELECT o.id, o.status, o.placed_at, c.email AS customer_email,
       json_agg(json_build_object('sku', i.sku, 'qty', i.qty)) AS items
FROM orders o
JOIN customers c ON c.id = o.customer_id
JOIN order_items i ON i.order_id = o.id
GROUP BY o.id, c.email
"""

The query must return the document ID column and must be deterministic: no now(), no random().

Environment variables

VariableDescription
DRIFT_CONFIGPath to driftbase.toml.
DRIFT_TOKENAPI token for Driftbase Cloud, instead of drift login.
DRIFT_LOGerror, warn, info (default) or debug.
DRIFT_METRICS_ADDRServe Prometheus metrics, for example :9464.