SQLite
Tradehall runs on PostgreSQL by default, and it can run on SQLite instead. SQLite keeps the whole database in one file in the storage volume, so there’s no database server to run, tune, or upgrade. It suits a single business on one small server: a 1 GB server is plenty, where PostgreSQL wants 2 GB.
Pick PostgreSQL if you expect many staff working at once, want a managed database from your host, or want to run more than one copy of the app. Pick SQLite when one server and less to look after matter more.
Installing with SQLite
Section titled “Installing with SQLite”The install script asks which database to use on a new install. To choose without the question:
curl -fsSL https://raw.githubusercontent.com/Hudsonville-Digital-Foundry/Tradehall/main/deploy/install.sh | sudo TRADEHALL_DATABASE=sqlite shThe script writes TRADEHALL_DATABASE=sqlite to /opt/tradehall/.env and uses deploy/compose.sqlite.yml as compose.yml: the app, the queue worker, and the scheduler, with no PostgreSQL container. The database is storage/database/tradehall.sqlite in the storage volume. Running the script again, and updates from Settings > About and updates, keep using the SQLite compose file because .env remembers the choice.
By hand: copy deploy/compose.sqlite.yml to the server as compose.yml, write a .env next to it with TRADEHALL_DATABASE=sqlite, APP_KEY, and APP_URL, then docker compose up -d.
Outside Docker, set DATABASE_URL to the file: sqlite:storage/database/tradehall.sqlite (relative to the app’s folder) or sqlite:///var/lib/tradehall/tradehall.sqlite (absolute). The folder must exist; the container’s entrypoint creates it.
How it runs
Section titled “How it runs”Connections use write-ahead logging, so pages keep reading while the worker or scheduler writes, and wait up to five seconds for a write lock instead of failing. Foreign keys are enforced as on PostgreSQL. Migrations, the database queue, sessions, and the cache all work the same.
Keep the storage volume on the server’s own disk. SQLite’s locking doesn’t work over network file systems such as NFS or SMB, and two servers must never share the file.
Amounts stay exact to the cent. SQLite has no exact decimal type and stores each amount as a floating point number, which holds about 15 digits, far more than any invoice needs, and Tradehall adds amounts up in Go with exact decimals rather than in SQL.
Backups
Section titled “Backups”Backups work as described in backups-and-storage.md, to the storage volume or a bucket, on the same schedule. A SQLite backup is a gzipped copy of the database file, named like tradehall-2026-12-06-080000-v0.2.0.sqlite.gz. Tradehall makes it with VACUUM INTO, which copies the database as it was at one moment while the app keeps running.
backup:restore takes the same arguments. It checks the backup is a healthy Tradehall database before touching anything, saves the current database as a ...-before-restore.sqlite.gz, then copies the backup in with SQLite’s backup API in one write. If the copy fails, the database is left as it was. A downloaded backup restores with --file, gzipped or not. A PostgreSQL backup can’t be restored into SQLite, or the other way round.
To copy the database off the server yourself, download a backup from Settings > Backups. Copying tradehall.sqlite while Tradehall runs can miss changes still in tradehall.sqlite-wal.
Moving to PostgreSQL later
Section titled “Moving to PostgreSQL later”There’s no built-in move between databases yet. If a business outgrows SQLite, install a new Tradehall on PostgreSQL and copy the data across with a tool such as pgloader, then point the domain at it.
Development
Section titled “Development”DATABASE_URL=sqlite:storage/database.sqlite works for local development too, with no PostgreSQL to install. Tests run on SQLite when DATABASE_URL is a sqlite: URL; each test gets a fresh in-memory database:
DATABASE_URL=sqlite:storage/test.sqlite go test ./...Two backup tests skip on SQLite, because an in-memory database has no file to copy; the backups package tests SQLite backups and restores against a real file. CI runs the whole suite on both databases. Raw SQL that differs between them branches on db.From(ctx).Dialect(), as the custom field filters in core/fields/lists.go do.