Appearance
Database & Migrations
Soma uses SQLx-backed storage for durable state such as join requests/decisions, memberships, and mailbox delivery.
What uses a database
soma-daemon(embedded in the Taurisrc-taurihost viadesktop-daemon, run in-process): SQLite file under the app's data dir —~/Library/Application Support/Soma/on macOS,~/.local/share/soma/on Linux (stage-specific-dev/-stagingsuffixes via@soma/desktop-config).somad bot(server peer): SQLx AnyPool with SQLite or Postgres (SOMA_DATABASE_URL, default./botd.db).
Both apply migrations at startup and fail fast if migrations cannot be applied.
Migrations
- Directory:
backend/crates/storage/migrations - Applied by:
backend/crates/daemon/src/lib.rs(the in-process daemon library) viasqlx::migrate!("../storage/migrations")backend/bins/somad/src/commands/bot/runtime.rsviasqlx::migrate!("../../crates/storage/migrations")
Access layer (repositories)
SQL is intentionally kept out of controllers/handlers. Repositories live in:
backend/crates/storage/src/membership.rsbackend/crates/storage/src/issuer.rsbackend/crates/storage/src/mailbox.rs
Repository wiring:
- Bootstrap:
backend/crates/storage/src/bootstrap.rs - Factory:
backend/crates/storage/src/lib.rs(RepositoryFactory)
Database URL conventions
- The code normalizes SQLite paths into
sqlite://...URLs viasoma_core::db::normalize_sqlite_url(backend/crates/core/src/db.rs). - For
somad bot,SOMA_DATABASE_URLcan be:- a
postgres://...URL, or - a SQLite URL/path (
sqlite:...or a filesystem path).
- a
Common workflows
Inspecting the desktop daemon DB (SQLite)
The file lives under the desktop app's data directory — on macOS that is ~/Library/Application Support/Soma/. On Linux it is ~/.local/share/soma/.
bash
sqlite3 "$HOME/Library/Application Support/Soma/soma.db" '.tables'Running against a fresh DB
- Delete the DB file (e.g., the desktop DB under the app data dir, or
backend/botd.dbfor the server bot) and restart the service. - Migrations will recreate the schema.
Postgres for the server bot (deployments)
- Set
SOMA_DATABASE_URL=postgres://...forsomad bot. - Ensure the database is reachable and credentials are correct; startup will fail if migrations cannot be applied.