Table of Contents

Last updated

PostgreSQL

Use PostgreSQL instead of SQLite when you need more write concurrency or must use existing database infrastructure.

Connection String

Windshift uses PostgreSQL instead of SQLite when a connection is configured. Prefer the split variables: Windshift builds the connection string from them, so the password never appears in a URL.

DB_TYPE=postgres
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=windshift
POSTGRES_PASSWORD=secret
POSTGRES_DB=windshift
POSTGRES_SSLMODE=disable
./windshift

POSTGRES_CONNECTION_STRING also accepts a full PostgreSQL URI. Keep it in the environment rather than on the command line, so credentials do not appear in process listings or shell history.

When PostgreSQL is configured, Windshift ignores the --db flag.

Connection Pool

Windshift limits the PostgreSQL pool size. This prevents a busy instance or agent traffic burst from exhausting database connections. Windshift sizes the pool from MAX_READ_CONNS:

SettingDefaultSource
Max open connections30MAX_READ_CONNS
Max idle connections15half of MAX_READ_CONNS

Windshift recycles idle connections after their lifetime and idle timeout. To raise the limit, increase MAX_READ_CONNS (--max-read-conns). Keep it below the PostgreSQL server’s max_connections. Reserve connections for other clients, runners, and sidecars.

Per-user concurrency

MAX_USER_CONCURRENCY (default 16) limits the simultaneous /api requests from one authenticated user or agent. This prevents one heavy client from monopolizing the pool. Set it to 0 to remove the limit.

Go’s database/sql package manages the pool.

Docker Compose Setup

This example matches the Docker guide: a pinned image tag from WINDSHIFT_VERSION, the required /tmp tmpfs, an explicit WebAuthn RP ID, and a health check on the Windshift service.

services:
  windshift:
    image: ghcr.io/windshiftapp/windshift:${WINDSHIFT_VERSION}
    restart: unless-stopped
    ports:
      - "8080:8080"
    tmpfs:
      - /tmp:exec,size=64M
    mem_limit: ${WINDSHIFT_CONTAINER_MEMORY_LIMIT:-2g}
    environment:
      - BASE_URL=https://windshift.example.com
      - SSO_SECRET=${SSO_SECRET}
      - WEBAUTHN_RP_ID=windshift.example.com
      - WINDSHIFT_MEMORY_LIMIT_MB=${WINDSHIFT_MEMORY_LIMIT_MB:-2048}
      - DB_TYPE=postgres
      - POSTGRES_HOST=postgres
      - POSTGRES_PORT=5432
      - POSTGRES_USER=windshift
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=windshift
      - POSTGRES_SSLMODE=disable
      - ATTACHMENT_PATH=/data/attachments
    volumes:
      - windshift-data:/data
    healthcheck:
      test: ["CMD", "/windshift", "healthcheck"]
      interval: 15s
      timeout: 5s
      retries: 5
      start_period: 30s
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: postgres:18
    restart: unless-stopped
    environment:
      - POSTGRES_USER=windshift
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=windshift
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U windshift"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  windshift-data:
  postgres-data:

Verify the connection

After startup, confirm that Windshift selected PostgreSQL and reached it:

docker compose logs windshift | grep "connecting to"
# connecting to PostgreSQL database

curl http://localhost:8080/readyz
# {"status":"ready","database":"ok","attachments":"ok"}

/readyz pings PostgreSQL on every request. If the database is unreachable, the probe returns HTTP 503 with status: not_ready and database: unavailable. It recovers once PostgreSQL is reachable again, without restarting Windshift. Starting in 0.9.6, an attachment outage alone returns HTTP 200 with status: degraded and database: ok. See Verify the deployment for the full readiness response.

PostgreSQL major upgrades

The Compose examples use PostgreSQL 18. Do not change a PostgreSQL image to a different major version when it uses an existing data volume. Use pg_upgrade or a dump and restore. PostgreSQL will not start a data directory created by another major version.

Schema Management

Windshift manages database schemas automatically. At startup, it runs embedded migration files for items, users, tests, workflows, portals, notifications, and permissions. It converts SQL placeholders between SQLite (?) and PostgreSQL ($1, $2, and similar) syntax.

Do not run manual schema setup or migration commands.

SSL/TLS

For a production PostgreSQL connection, set sslmode in the connection string. With the split variables, use POSTGRES_SSLMODE:

DB_TYPE=postgres
POSTGRES_HOST=db.example.com
POSTGRES_USER=windshift
POSTGRES_PASSWORD=secret
POSTGRES_DB=windshift
POSTGRES_SSLMODE=require

POSTGRES_SSLMODE defaults to disable. This setting fits the bundled postgres container on the same Docker network. For a remote or managed database, use require, verify-ca, or verify-full. Accepted modes are disable, allow, prefer, require, verify-ca, and verify-full.

Backups

Use standard PostgreSQL backup tools:

# Logical backup
pg_dump -U windshift windshift > backup.sql

# Compressed backup
pg_dump -U windshift -Fc windshift > backup.dump

# Restore
pg_restore -U windshift -d windshift backup.dump

Migrating from SQLite

To migrate an existing SQLite database to PostgreSQL:

  1. Set up a new PostgreSQL database.
  2. Start Windshift with the PostgreSQL connection string. Windshift creates all tables.
  3. Export the SQLite data. Import it into PostgreSQL with standard tools.

There is no built-in migration command at this time.