Persistence

PostgreSQL configuration

A fresh deployment can validate PostgreSQL, persist the choice and initialize the system schema. PostgreSQL is available once the connection validates and the schema initializes.

Dashboard flow

  1. Start a fresh Trestle instance on loopback.
  2. Choose PostgreSQL in First-run setup.
  3. Enter a TLS-protected connection URL and select Test and use database.
  4. Trestle verifies the server without returning the URL.
  5. Restart when prompted; Trestle initializes the PostgreSQL schema and returns to administrator setup.

Interrupted setup is resumable: the provider choice persists before restart, administrator creation stays available until one administrator commits, and setup never reopens afterward.

Headless flow

export TRESTLE_DATABASE_PROVIDER=postgres
export TRESTLE_DATABASE_URL='postgres://trestle:secret@db.internal/trestle?sslmode=verify-full'
./trestle

Explicit startup configuration takes precedence and makes browser database controls read-only.

Pool and connection controls

SettingDefaultBoundary
Maximum open101-500
Maximum idle20 to maximum open
Connect timeout10sWhole seconds, more than zero, at most 1m
Connection lifetime30m0 to 24h

The connect timeout is injected as the driver's connect_timeout into every PostgreSQL connection configuration, including the first-run connection test, so a silently unreachable server cannot stall startup or setup indefinitely. It must be a whole number of seconds because the driver cannot represent sub-second precision; Trestle rejects such values rather than rounding them.

TLS and secrets

Remote connections cannot use sslmode=disable. Stored setup state is atomically replaced at mode 0600; URLs are not returned by APIs or included in diagnostics. Prefer an operator secret manager for production.