Database
The database holds everything about your documents — the document records, annotations, tokens, and the audit log. (The PDF bytes themselves live in the object store.) The server supports two drivers.
| SQLite | Postgres | |
|---|---|---|
| Setup | None — a single file | A running Postgres |
| Replicas | One instance only | Many |
| Best for | Dev, single host, low traffic | Production, high availability |
SQLite (default)#
SQLite needs nothing to set up — it’s a single file on disk. This is the default, and it’s what the Quick start uses.
CLOUDPDF_DB_DRIVER=sqlite
CLOUDPDF_DB_SQLITE_PATH=/data/cloudpdf.dbSQLite has a single writer. Run exactly one server instance against a SQLite database, and put the file on a persistent volume. To run more than one instance, switch to Postgres.
Postgres#
Postgres is the choice for production and the only way to run multiple replicas. Point the server at any Postgres 14+ database — managed (RDS, Cloud SQL, Neon, Supabase) or one you run yourself.
CLOUDPDF_DB_DRIVER=postgres
CLOUDPDF_DB_URL=postgres://user:password@host:5432/cloudpdfWith Postgres, take migrations out of the boot path so replicas don’t race — run them as an explicit step and refuse to serve on a stale schema:
CLOUDPDF_AUTO_MIGRATE=0
CLOUDPDF_FAIL_ON_PENDING=1See Migrations for the recommended flow per deployment method.
Moving from SQLite to Postgres#
A common path is to prototype on SQLite and move to Postgres as you grow. The move is a configuration change plus a one-time data migration:
- Stand up a Postgres database.
- Point a server at it and run
cloudpdf-server migrate upto create the schema. - Migrate your existing rows (see
MIGRATIONS.mdin the server package for the export/import procedure). - Switch your running deployment’s
CLOUDPDF_DB_DRIVERandCLOUDPDF_DB_URL, and scale up replicas.
Documents stored in a cloud bucket don’t move during this — only the database changes. Keeping bytes in object storage is what makes the database swap clean.
Verify the connection#
db doctor connects, validates the schema, and prints version info — a quick way
to confirm credentials and connectivity:
cloudpdf-server db doctor