Skip to content

Adapters: PostgreSQL (@invariant/postgres)

The official storage adapter for production self-hosting.

ts
import { postgres } from "@invariant/postgres";
import pg from "pg";

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });

const store = postgres({ pool });

Table Schema

  • workflow_runs: Manages run metadata and status.
  • workflow_events: Immutable event log with monotonic sequence seq.
  • workflow_states: Revision-controlled execution state.
  • workflow_outbox: Outbox side-effects queue.
  • workflow_leases: Optimistic lease locks for workers.

Invariant Durable Execution Engine.