Skip to main content
The PostgreSQL backend is recommended for production. It supports multiple concurrent workers, provides strong durability guarantees, and scales with your application.

Install

The PostgreSQL backend requires the postgres driver. Install it alongside OpenWorkflow:

Setup

Connection URL

The connection URL follows the standard PostgreSQL format:
Examples:
  • Local: postgresql://postgres:postgres@localhost:5432/openworkflow
  • With SSL: postgresql://user:[email protected]:5432/db?sslmode=require

Configuration Options

Migrations

By default, BackendPostgres.connect() runs database migrations automatically. This creates the configured schema (default: openworkflow) and required tables. To disable automatic migrations:
When disabled, ensure you run migrations separately before starting workers.

Schema

OpenWorkflow creates tables in the configured schema (default: openworkflow):
  • <schema>.workflow_runs - Stores workflow run state
  • <schema>.step_attempts - Stores step execution history
This keeps OpenWorkflow data separate from your application tables.

Namespaces

Use namespaceId to isolate environments or tenants:
See Namespaces for more details.

Config File Example

For use with the CLI, create openworkflow.config.ts:

Connection Pooling

The PostgreSQL backend uses connection pooling internally. For most applications, the default pool settings work well. The pool is managed automatically and connections are reused across workflow executions.

Requirements

  • PostgreSQL 14 or later
  • The connecting user needs permissions to:
    • Create schemas (for migrations)
    • Create tables (for migrations)
    • Read/write to the configured schema (default: openworkflow)