{
  "topic": "config.database",
  "path": [
    "config",
    "database"
  ],
  "title": "database configuration",
  "synopsis": "config.database — storage backend selection and per-backend connection settings.",
  "body": "# config.database\n\n## NAME\n\nconfig.database — storage backend selection and per-backend connection settings.\n\n## SYNOPSIS\n\nSelect the backend with `CYODA_STORAGE_BACKEND`. Configure the chosen backend via its\nper-backend variables (`CYODA_SQLITE_*` or `CYODA_POSTGRES_*`). The `memory` backend\nrequires no additional configuration.\n\n## OPTIONS\n\n### Backend selection\n\n- `CYODA_STORAGE_BACKEND` — storage backend to use: `sqlite`, `postgres`, or `memory`\n  (bare default: `memory`; `cyoda init` writes `CYODA_STORAGE_BACKEND=sqlite` to\n  `~/.config/cyoda/cyoda.env`, so the effective default after `cyoda init` is `sqlite`)\n\n### SQLite backend (`CYODA_SQLITE_*`)\n\nUsed when `CYODA_STORAGE_BACKEND=sqlite`.\n\n- `CYODA_SQLITE_PATH` — path to the SQLite database file (default: `~/.local/share/cyoda/cyoda.db` on Linux/macOS XDG; `%LocalAppData%\\cyoda\\cyoda.db` on Windows)\n- `CYODA_SQLITE_AUTO_MIGRATE` — run embedded SQL migrations on startup (default: `true`)\n- `CYODA_SQLITE_BUSY_TIMEOUT` — busy timeout for lock contention (default: `5s`)\n- `CYODA_SQLITE_CACHE_SIZE` — SQLite page cache size in KiB (default: `64000`)\n- `CYODA_SQLITE_SEARCH_SCAN_LIMIT` — max rows scanned per search query (default: `100000`)\n\nThe prefix `CYODA_SQLITE_` is used to namespace all SQLite configuration variables.\n\n### PostgreSQL backend (`CYODA_POSTGRES_*`)\n\nUsed when `CYODA_STORAGE_BACKEND=postgres`.\n\n- `CYODA_POSTGRES_URL` — PostgreSQL connection string, e.g. `postgres://user:pass@host/db`\n  (required when using postgres backend)\n- `CYODA_POSTGRES_URL_FILE` — file path for `CYODA_POSTGRES_URL` (takes precedence)\n- `CYODA_POSTGRES_MAX_CONNS` — maximum pool connections (default: `25`)\n- `CYODA_POSTGRES_MIN_CONNS` — minimum pool connections (default: `5`)\n- `CYODA_POSTGRES_MAX_CONN_IDLE_TIME` — max idle time before closing a connection (default: `5m`)\n- `CYODA_POSTGRES_AUTO_MIGRATE` — run embedded SQL migrations on startup (default: `true`)\n\nThe prefix `CYODA_POSTGRES_` is used to namespace all PostgreSQL configuration variables.\n\n### Memory backend\n\nUsed when `CYODA_STORAGE_BACKEND=memory`. No additional configuration needed. Data is\nnot persisted across restarts. Suitable for development and testing only.\n\n## EXAMPLES\n\n**SQLite (default after `cyoda init`):**\n\n```\nCYODA_STORAGE_BACKEND=sqlite\nCYODA_SQLITE_PATH=/var/data/cyoda.db\nCYODA_SQLITE_AUTO_MIGRATE=true\n```\n\n**PostgreSQL:**\n\n```\nCYODA_STORAGE_BACKEND=postgres\nCYODA_POSTGRES_URL=postgres://cyoda:secret@localhost:5432/cyoda\nCYODA_POSTGRES_MAX_CONNS=50\n```\n\n**In-memory (tests/dev):**\n\n```\nCYODA_STORAGE_BACKEND=memory\n```\n\n## SEE ALSO\n\n- config\n- run\n",
  "sections": [
    {
      "name": "NAME",
      "body": "config.database — storage backend selection and per-backend connection settings."
    },
    {
      "name": "SYNOPSIS",
      "body": "Select the backend with `CYODA_STORAGE_BACKEND`. Configure the chosen backend via its\nper-backend variables (`CYODA_SQLITE_*` or `CYODA_POSTGRES_*`). The `memory` backend\nrequires no additional configuration."
    },
    {
      "name": "OPTIONS",
      "body": "### Backend selection\n\n- `CYODA_STORAGE_BACKEND` — storage backend to use: `sqlite`, `postgres`, or `memory`\n  (bare default: `memory`; `cyoda init` writes `CYODA_STORAGE_BACKEND=sqlite` to\n  `~/.config/cyoda/cyoda.env`, so the effective default after `cyoda init` is `sqlite`)\n\n### SQLite backend (`CYODA_SQLITE_*`)\n\nUsed when `CYODA_STORAGE_BACKEND=sqlite`.\n\n- `CYODA_SQLITE_PATH` — path to the SQLite database file (default: `~/.local/share/cyoda/cyoda.db` on Linux/macOS XDG; `%LocalAppData%\\cyoda\\cyoda.db` on Windows)\n- `CYODA_SQLITE_AUTO_MIGRATE` — run embedded SQL migrations on startup (default: `true`)\n- `CYODA_SQLITE_BUSY_TIMEOUT` — busy timeout for lock contention (default: `5s`)\n- `CYODA_SQLITE_CACHE_SIZE` — SQLite page cache size in KiB (default: `64000`)\n- `CYODA_SQLITE_SEARCH_SCAN_LIMIT` — max rows scanned per search query (default: `100000`)\n\nThe prefix `CYODA_SQLITE_` is used to namespace all SQLite configuration variables.\n\n### PostgreSQL backend (`CYODA_POSTGRES_*`)\n\nUsed when `CYODA_STORAGE_BACKEND=postgres`.\n\n- `CYODA_POSTGRES_URL` — PostgreSQL connection string, e.g. `postgres://user:pass@host/db`\n  (required when using postgres backend)\n- `CYODA_POSTGRES_URL_FILE` — file path for `CYODA_POSTGRES_URL` (takes precedence)\n- `CYODA_POSTGRES_MAX_CONNS` — maximum pool connections (default: `25`)\n- `CYODA_POSTGRES_MIN_CONNS` — minimum pool connections (default: `5`)\n- `CYODA_POSTGRES_MAX_CONN_IDLE_TIME` — max idle time before closing a connection (default: `5m`)\n- `CYODA_POSTGRES_AUTO_MIGRATE` — run embedded SQL migrations on startup (default: `true`)\n\nThe prefix `CYODA_POSTGRES_` is used to namespace all PostgreSQL configuration variables.\n\n### Memory backend\n\nUsed when `CYODA_STORAGE_BACKEND=memory`. No additional configuration needed. Data is\nnot persisted across restarts. Suitable for development and testing only."
    },
    {
      "name": "EXAMPLES",
      "body": "**SQLite (default after `cyoda init`):**\n\n```\nCYODA_STORAGE_BACKEND=sqlite\nCYODA_SQLITE_PATH=/var/data/cyoda.db\nCYODA_SQLITE_AUTO_MIGRATE=true\n```\n\n**PostgreSQL:**\n\n```\nCYODA_STORAGE_BACKEND=postgres\nCYODA_POSTGRES_URL=postgres://cyoda:secret@localhost:5432/cyoda\nCYODA_POSTGRES_MAX_CONNS=50\n```\n\n**In-memory (tests/dev):**\n\n```\nCYODA_STORAGE_BACKEND=memory\n```"
    },
    {
      "name": "SEE ALSO",
      "body": "- config\n- run"
    }
  ],
  "see_also": [
    "config",
    "run"
  ],
  "stability": "stable",
  "actions": []
}
