ObjectStackObjectStack

Driver Postgres

Driver Postgres protocol schemas

PostgreSQL driver configuration — the config slot of a datasource whose driver resolves to postgres (pg / postgresql).

ENFORCED as of #4410: DatasourceSchema parses config against this schema, so a misspelled connection key fails at authoring time instead of leaving the datasource on the client's localhost defaults. Every key here is read by createDefaultDatasourceDriverFactory (→ SqlDriver, knex pg).

Pool sizing is NOT here: it lives in the driver-agnostic datasource.pool block, which the factory now honours for every SQL driver.

Source: packages/spec/src/data/driver/postgres.zod.ts

TypeScript Usage

import { PostgresConfigSchema } from '@objectstack/spec/data';
import type { PostgresConfig } from '@objectstack/spec/data';

// Validate data
const result = PostgresConfigSchema.parse(data);

PostgresConfig

PostgreSQL connection configuration

Properties

PropertyTypeRequiredDescription
urlstringoptionalConnection URI (supersedes the discrete fields; must be a URL pg can parse; must not embed a password — bind the secret instead)
hoststringoptional (default: "localhost")Host address
portintegeroptional (default: 5432)Port number
databasestringoptionalDatabase name
usernamestringoptionalAuthentication user
passwordneveroptionalSet through the connection form's secret field or external.credentialsRef — encrypted into sys_secret, never stored in config (#7990)
sslbooleanoptionalEnable TLS. Certificates go in the datasource-level ssl block.
schemastringoptional (default: "public")Default schema (knex searchPath)
applicationNamestringoptionalPostgres application_name
statementTimeoutintegeroptionalAbort statements running longer than this (ms)
autoMigrateEnum<'off' | 'safe'>optionalDev-only non-destructive schema self-heal (#2186)

On this page