Skip to content

Database

Stirling Image uses SQLite with Drizzle ORM for data persistence. The schema is defined in apps/api/src/db/schema.ts.

The database file lives at the path set by DB_PATH (defaults to ./data/stirling.db). In Docker, mount the /data volume to persist it across container restarts.

Tables

users

Stores user accounts. Created automatically on first run from DEFAULT_USERNAME and DEFAULT_PASSWORD.

ColumnTypeNotes
idintegerPrimary key, auto-increment
usernametextUnique, required
passwordHashtextbcrypt hash
roletextadmin or user
mustChangePasswordintegerBoolean flag for forced password reset
createdAttextISO timestamp
updatedAttextISO timestamp

sessions

Active login sessions. Each row ties a session token to a user.

ColumnTypeNotes
idtextPrimary key (session token)
userIdintegerForeign key to users.id
expiresAttextISO timestamp
createdAttextISO timestamp

api_keys

API keys for programmatic access. The raw key is shown once on creation; only the hash is stored.

ColumnTypeNotes
idintegerPrimary key, auto-increment
userIdintegerForeign key to users.id
keyHashtextSHA-256 hash of the key
nametextUser-provided label
createdAttextISO timestamp
lastUsedAttextUpdated on each authenticated request

Keys are prefixed with si_ followed by 96 hex characters (48 random bytes).

pipelines

Saved tool chains that users create in the UI.

ColumnTypeNotes
idintegerPrimary key, auto-increment
nametextPipeline name
descriptiontextOptional description
stepstextJSON array of { toolId, settings } objects
createdAttextISO timestamp

jobs

Tracks processing jobs for progress reporting and cleanup.

ColumnTypeNotes
idtextPrimary key (UUID)
typetextTool or pipeline identifier
statustextqueued, processing, completed, or failed
progressinteger0-100 percentage
inputFilestextJSON array of input file paths
outputPathtextPath to the result file
settingstextJSON of the tool settings used
errortextError message if failed
createdAttextISO timestamp
completedAttextISO timestamp

settings

Key-value store for server-wide settings that admins can change from the UI.

ColumnTypeNotes
keytextPrimary key
valuetextSetting value
updatedAttextISO timestamp

Migrations

Drizzle handles schema migrations. The config is in apps/api/drizzle.config.ts. During development, run:

bash
pnpm --filter @stirling-image/api drizzle-kit push

In production, the schema is applied automatically on startup.