Skip to content
ricochet

Database

ricochet stores deployed content, users, access controls, API keys, logs, and analytics in a database. The database is SQLite or Postgres, selected by the [database] section of ricochet-config.toml.

Without a [database] section, ricochet uses SQLite. SQLite is bundled and statically linked within the ricochet binary, so no external installation is required. The database file is RICOCHET_HOME/ricochet.sqlite3 and is created automatically on first start.

Point [database] url at an empty Postgres database whose role is allowed to create tables:

ricochet-config.toml
[database]
url = "postgres://<user>:<password>@db.example.com:<port>/<db name>"

The same setting is available as the RICOCHET_DATABASE__URL environment variable. Both postgres:// and postgresql:// URLs are accepted. ricochet creates the schema on first start and migrates it on every upgrade, exactly as it does for SQLite.

Use Postgres when the database must outlive a single host, or when it must be shared by more than one ricochet instance.

  1. Stop ricochet.

  2. Create an empty Postgres database and a role that owns it.

  3. Copy the data:

    Terminal window
    ricochet db copy \
    --from sqlite:///var/lib/ricochet/data/ricochet.sqlite3 \
    --to postgres://<user>:<password>@db.example.com:<port>/<db name>

    The command creates the schema on the target, refuses a target that already holds rows, copies every table inside one transaction, and prints the row count per table.

  4. Add the [database] section to ricochet-config.toml.

  5. Start ricochet.

Keep the same RICOCHET_HOME and secrets directory. Environment variables and Git credentials are stored encrypted, and only the existing keypair can read them. Sessions are not copied, so users must sign in again. The SQLite file is left untouched and serves as a backup.

ricochet automatically handles database schema migrations when up-or downgrading to new versions.