|
| 1 | +--- |
| 2 | +title: "Database Configuration" |
| 3 | +description: "Field-by-field reference for configuring PostgreSQL and SQLite in Compozy." |
| 4 | +icon: Database |
| 5 | +--- |
| 6 | + |
| 7 | +## `database.driver` |
| 8 | + |
| 9 | +Select the backing store for Compozy metadata. |
| 10 | + |
| 11 | +| Property | Value | |
| 12 | +|----------|-------| |
| 13 | +| **Type** | `string` | |
| 14 | +| **Options** | `postgres` \| `sqlite` | |
| 15 | +| **Default** | `postgres` | |
| 16 | +| **Environment Variable** | `DB_DRIVER` or `COMPOZY_DB_DRIVER` | |
| 17 | + |
| 18 | +Omitting `driver` keeps PostgreSQL as the default. |
| 19 | + |
| 20 | +## PostgreSQL Fields |
| 21 | + |
| 22 | +Use these fields when `driver: postgres` (or omitted): |
| 23 | + |
| 24 | +<Table> |
| 25 | + <TableHeader> |
| 26 | + <TableRow> |
| 27 | + <TableHead>Field</TableHead> |
| 28 | + <TableHead>Type</TableHead> |
| 29 | + <TableHead>Required</TableHead> |
| 30 | + <TableHead>Description</TableHead> |
| 31 | + </TableRow> |
| 32 | + </TableHeader> |
| 33 | + <TableBody> |
| 34 | + <TableRow> |
| 35 | + <TableCell>`host`</TableCell> |
| 36 | + <TableCell>string</TableCell> |
| 37 | + <TableCell>Yes*</TableCell> |
| 38 | + <TableCell>Hostname or IP address of the PostgreSQL server (*omit when using `conn_string`).</TableCell> |
| 39 | + </TableRow> |
| 40 | + <TableRow> |
| 41 | + <TableCell>`port`</TableCell> |
| 42 | + <TableCell>string</TableCell> |
| 43 | + <TableCell>No</TableCell> |
| 44 | + <TableCell>Port number (default `5432`).</TableCell> |
| 45 | + </TableRow> |
| 46 | + <TableRow> |
| 47 | + <TableCell>`user`</TableCell> |
| 48 | + <TableCell>string</TableCell> |
| 49 | + <TableCell>Yes*</TableCell> |
| 50 | + <TableCell>Database user used for migrations and runtime operations.</TableCell> |
| 51 | + </TableRow> |
| 52 | + <TableRow> |
| 53 | + <TableCell>`password`</TableCell> |
| 54 | + <TableCell>string</TableCell> |
| 55 | + <TableCell>Yes*</TableCell> |
| 56 | + <TableCell>Password for the specified user.</TableCell> |
| 57 | + </TableRow> |
| 58 | + <TableRow> |
| 59 | + <TableCell>`dbname`</TableCell> |
| 60 | + <TableCell>string</TableCell> |
| 61 | + <TableCell>Yes*</TableCell> |
| 62 | + <TableCell>Name of the PostgreSQL database where Compozy stores metadata.</TableCell> |
| 63 | + </TableRow> |
| 64 | + <TableRow> |
| 65 | + <TableCell>`conn_string`</TableCell> |
| 66 | + <TableCell>string</TableCell> |
| 67 | + <TableCell>No</TableCell> |
| 68 | + <TableCell>PostgreSQL DSN (`postgres://user:pass@host:port/db?sslmode=require`). When provided, overrides individual connection fields.</TableCell> |
| 69 | + </TableRow> |
| 70 | + <TableRow> |
| 71 | + <TableCell>`sslmode`</TableCell> |
| 72 | + <TableCell>string</TableCell> |
| 73 | + <TableCell>No</TableCell> |
| 74 | + <TableCell>SSL/TLS mode (`disable`, `require`, `verify-ca`, `verify-full`). Defaults to `require` in production builds.</TableCell> |
| 75 | + </TableRow> |
| 76 | + <TableRow> |
| 77 | + <TableCell>`max_open_conns`</TableCell> |
| 78 | + <TableCell>int</TableCell> |
| 79 | + <TableCell>No</TableCell> |
| 80 | + <TableCell>Upper bound for concurrent connections in the pool.</TableCell> |
| 81 | + </TableRow> |
| 82 | + <TableRow> |
| 83 | + <TableCell>`max_idle_conns`</TableCell> |
| 84 | + <TableCell>int</TableCell> |
| 85 | + <TableCell>No</TableCell> |
| 86 | + <TableCell>Number of warm idle connections the pool maintains.</TableCell> |
| 87 | + </TableRow> |
| 88 | + </TableBody> |
| 89 | +</Table> |
| 90 | + |
| 91 | +```yaml title="PostgreSQL Example" |
| 92 | +database: |
| 93 | + driver: postgres |
| 94 | + host: postgres.internal |
| 95 | + port: 5432 |
| 96 | + user: compozy |
| 97 | + password: ${DB_PASSWORD} |
| 98 | + dbname: compozy |
| 99 | + sslmode: verify-full |
| 100 | + max_open_conns: 50 |
| 101 | + max_idle_conns: 10 |
| 102 | +``` |
| 103 | +
|
| 104 | +## SQLite Fields |
| 105 | +
|
| 106 | +Use these fields when `driver: sqlite`: |
| 107 | + |
| 108 | +<Table> |
| 109 | + <TableHeader> |
| 110 | + <TableRow> |
| 111 | + <TableHead>Field</TableHead> |
| 112 | + <TableHead>Type</TableHead> |
| 113 | + <TableHead>Required</TableHead> |
| 114 | + <TableHead>Description</TableHead> |
| 115 | + </TableRow> |
| 116 | + </TableHeader> |
| 117 | + <TableBody> |
| 118 | + <TableRow> |
| 119 | + <TableCell>`path`</TableCell> |
| 120 | + <TableCell>string</TableCell> |
| 121 | + <TableCell>Yes</TableCell> |
| 122 | + <TableCell>Path to the SQLite file. Use `:memory:` for ephemeral, in-memory deployments.</TableCell> |
| 123 | + </TableRow> |
| 124 | + <TableRow> |
| 125 | + <TableCell>`busy_timeout`</TableCell> |
| 126 | + <TableCell>int</TableCell> |
| 127 | + <TableCell>No</TableCell> |
| 128 | + <TableCell>Milliseconds SQLite waits before returning `database is locked`.</TableCell> |
| 129 | + </TableRow> |
| 130 | + <TableRow> |
| 131 | + <TableCell>`journal_mode`</TableCell> |
| 132 | + <TableCell>string</TableCell> |
| 133 | + <TableCell>No</TableCell> |
| 134 | + <TableCell>Transaction journal mode. `wal` is recommended for moderate concurrency.</TableCell> |
| 135 | + </TableRow> |
| 136 | + <TableRow> |
| 137 | + <TableCell>`synchronous`</TableCell> |
| 138 | + <TableCell>string</TableCell> |
| 139 | + <TableCell>No</TableCell> |
| 140 | + <TableCell>Durability level: `full`, `normal`, or `off`.</TableCell> |
| 141 | + </TableRow> |
| 142 | + </TableBody> |
| 143 | +</Table> |
| 144 | + |
| 145 | +```yaml title="SQLite Example" |
| 146 | +database: |
| 147 | + driver: sqlite |
| 148 | + path: ./data/compozy.db |
| 149 | + busy_timeout: 5000 |
| 150 | + journal_mode: wal |
| 151 | + synchronous: normal |
| 152 | +``` |
| 153 | + |
| 154 | +<Callout type="error"> |
| 155 | +SQLite deployments **must** configure an external vector database provider. See the [vector database guide](/docs/knowledge-bases/vector-databases) for supported options. |
| 156 | +</Callout> |
| 157 | + |
| 158 | +## Environment Variables |
| 159 | + |
| 160 | +CLI flags and environment variables override configuration values: |
| 161 | + |
| 162 | +| Variable | Description | |
| 163 | +|----------|-------------| |
| 164 | +| `COMPOZY_DB_DRIVER` | Overrides `database.driver`. | |
| 165 | +| `COMPOZY_DB_HOST` | PostgreSQL host. | |
| 166 | +| `COMPOZY_DB_PORT` | PostgreSQL port. | |
| 167 | +| `COMPOZY_DB_NAME` | PostgreSQL database name. | |
| 168 | +| `COMPOZY_DB_USER` | PostgreSQL user. | |
| 169 | +| `COMPOZY_DB_PASSWORD` | PostgreSQL password. | |
| 170 | +| `COMPOZY_DB_CONN_STRING` | PostgreSQL connection string. | |
| 171 | +| `COMPOZY_DB_PATH` | SQLite file or `:memory:` path. | |
| 172 | +| `COMPOZY_DB_BUSY_TIMEOUT` | Millisecond timeout for SQLite locks. | |
| 173 | + |
| 174 | +CLI precedence follows the order: **flags → environment → configuration file → defaults**. |
| 175 | + |
| 176 | +## Related Topics |
| 177 | + |
| 178 | +<ReferenceCardList> |
| 179 | + <ReferenceCard |
| 180 | + title="Database Overview" |
| 181 | + description="Decide when to run PostgreSQL or SQLite." |
| 182 | + href="/docs/database/overview" |
| 183 | + icon="Database" |
| 184 | + /> |
| 185 | + <ReferenceCard |
| 186 | + title="PostgreSQL Driver" |
| 187 | + description="Production setup and tuning guidance." |
| 188 | + href="/docs/database/postgresql" |
| 189 | + icon="ServerCog" |
| 190 | + /> |
| 191 | + <ReferenceCard |
| 192 | + title="SQLite Driver" |
| 193 | + description="Edge deployments and concurrency limits." |
| 194 | + href="/docs/database/sqlite" |
| 195 | + icon="HardDrive" |
| 196 | + /> |
| 197 | +</ReferenceCardList> |
0 commit comments