# db-operator-database

PostgreSQL database, login role, and credentials Secret for one application, created by DB Operator

This page is generated from [`kix/packages/experimental/db-operator-database`](https://github.com/kix-run/kix/tree/main/kix/packages/experimental/db-operator-database).

| | |
| --- | --- |
| Stability | Experimental |
| `package` value | `packages.experimental.db-operator-database` |
| Default aliases | `database` |

## Dependencies

Kix matches each dependency below to another package instance by instance name, alias, or role. To bind a specific instance, set [`deps.<name>`](/docs/reference/instances-and-composition/#deps) in your cluster definition. See [Declaring dependencies](/docs/reference/package-anatomy/#declaring-dependencies) for how required and optional dependencies work.

| Dependency | Requirement |
| --- | --- |
| `dbInstance` | Required |
| `dbOperator` | Required |

## Options

### `extensions`

PostgreSQL extensions to enable in this database (`spec.postgres.extensions`).
Write each entry as an extension name such as `"citext"` (or
`{ name = "citext"; version = null; }`, which application packages may pass
automatically). Every listed extension must be installed on the PostgreSQL
server. Kix rejects non-null `version` values because DB Operator always
installs the server's default version.

- **Type:** `list of (string or (submodule))`
- **Default:** `[ ]`

### `extraSpec`

Additional fields merged into the `Database` `spec`, such as
`postgres.schemas` or `deletionProtected` (which defaults to `true`). Kix
rejects `instance`, `secretName`, `existingUser`, `credentials.templates`,
`secretsTemplates`, and `postgres.extensions` here because this package
manages those settings.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    postgres = {
      schemas = [
        "app"
      ];
    };
  }
  ```

### `templates`

Extra keys for DB Operator to render into the `<instance>-credentials` Secret.
Each value is a Go template that can use the fields `.Username`, `.Password`,
`.Hostname`, `.Port`, `.Database`, and `.Protocol`, and the functions
`.Secret`, `.ConfigMap`, `.Query`, and `.InstanceVar`. Kix rejects any other
template field, as well as key names already provided or reserved (`POSTGRES_DB`,
`POSTGRES_USER`, `POSTGRES_PASSWORD`, `username`, `password`, `DB`, `USER`,
`PASSWORD`, `CLICKHOUSE_DB`, `CLICKHOUSE_USER`, and `CLICKHOUSE_PASSWORD`). DB
Operator inserts values without escaping, so special characters in a generated
password can break a URL template.

- **Type:** `attribute set of string`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    DATABASE_URL = "postgresql://{{ .Username }}:{{ .Password }}@{{ .Hostname }}:{{ .Port }}/{{ .Database }}";
  }
  ```