DATABASE_URL.paperclip/.envconfig.database.connectionString- embedded PostgreSQL under
~/.paperclip/instances/<instance>/db
packages/db/src/migrations/meta/_journal.json is the canonical migration order.
Runtime Modes
| Mode | When it is selected | Notes |
|---|---|---|
| Embedded PostgreSQL | No external connection string is configured | Default local runtime |
| External PostgreSQL | DATABASE_URL, .paperclip/.env, or config points at Postgres | Use for paperclip_prod, Docker Postgres, or hosted providers |
Embedded PostgreSQL
LeaveDATABASE_URL unset:
- creates
~/.paperclip/instances/default/db/ - ensures the
paperclipdatabase exists - inspects and applies pending migrations through the DB package bootstrap flow
- starts serving requests
External PostgreSQL
Use external PostgreSQL when you want the app to targetpaperclip_prod, local Docker Postgres, or a hosted provider.
Local Docker example:
Migration Workflow
Use the repo migration flow, notdrizzle-kit push, for real runtime upgrades:
Backup And Restore
Create a backup with:- backup dir:
~/.paperclip/instances/<instance>/data/backups - retention: 30 days
- backup target follows the same DB resolution order as runtime startup
packages/db/src/backup-lib.ts. That path is exercised today by controlled operator flows and worktree seeding; it is not yet wrapped in a standalone public db:restore command.
ClickHouse Mirror
Paperclip can optionally mirror append-heavy telemetry into ClickHouse. PostgreSQL remains canonical; ClickHouse is an additive analytics/event warehouse. Today the server mirrors these tables on write:heartbeat_run_eventscost_eventsfinance_eventsperformance_ledger
- disabled unless ClickHouse is configured
- non-blocking for app startup
- write-through for new events only
- no automated historical backfill