Skip to content

PostgreSQL target

TwinCommit applies changes to PostgreSQL with batched INSERT … ON CONFLICT upserts and deletes by primary key. Snapshots use binary COPY into a staging table. The checkpoint is written in the same transaction as each batch.

Supported: PostgreSQL 13–18 and managed services (RDS, Aurora, Azure Flexible Server, Cloud SQL, AlloyDB).

target:
type: postgres
dsn: postgres://twincommit:${PG_PASSWORD}@pghost:5432/analytics?sslmode=require
state_schema: twincommit
CREATE ROLE twincommit LOGIN PASSWORD '********';
GRANT CREATE ON DATABASE analytics TO twincommit; -- state schema + ddl -apply
GRANT USAGE, CREATE ON SCHEMA sales TO twincommit;
GRANT INSERT, UPDATE, DELETE, SELECT, TRUNCATE ON ALL TABLES IN SCHEMA sales TO twincommit;

twincommit ddl prints CREATE TABLE statements, and twincommit ddl -apply runs them. It only creates tables that do not exist, so you can also create them yourself. Column names are the lower-cased source names by default.