---
# Generated by kapten-docs from the CLI's command tree. DO NOT EDIT.
title: "kapten databases"
description: "Create and manage databases."
sidebar:
  label: "databases"
---

Every command takes the [global flags](/cli/reference#global-flags).

## kapten databases create-mongodb

Creates a MongoDB database in an environment.

```bash
kapten databases create-mongodb <project-id> <environment-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
oneOf{
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:IN_CLUSTER) Database provisioning strategy.
      }
    }
  }
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:MANAGED) Database provisioning strategy.
      }
    }
  }
}
```

Example:

```bash
kapten databases create-mongodb <project-id> <environment-id> <input.json
```

## kapten databases create-mysql

Creates a MySQL database in an environment.

```bash
kapten databases create-mysql <project-id> <environment-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
oneOf{
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:IN_CLUSTER) Database provisioning strategy.
      }
    }
  }
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:MANAGED) Database provisioning strategy.
      }
    }
  }
}
```

Example:

```bash
kapten databases create-mysql <project-id> <environment-id> <input.json
```

## kapten databases create-postgresql

Creates a PostgreSQL database in an environment.

```bash
kapten databases create-postgresql <project-id> <environment-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
oneOf{
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:IN_CLUSTER) Database provisioning strategy.
      }
    }
  }
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:MANAGED) Database provisioning strategy.
      }
    }
  }
}
```

Example:

```bash
kapten databases create-postgresql <project-id> <environment-id> <input.json
```

## kapten databases create-redis

Creates a Redis database in an environment.

```bash
kapten databases create-redis <project-id> <environment-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
oneOf{
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:IN_CLUSTER) Database provisioning strategy.
      }
    }
  }
  allOf{
    allOf{
      {
        accessibility*: allOf{
          <...>
        }
        description: (string) Optional database description.
        name*: (string pattern:\S minLen:1) Name of the database.
        version*: (string) Database engine version.
      }
      {
        configuration*: {
          activate_backups: <...>
          activate_high_availability: <...>
          database_name: <...>
          encrypt_disk: <...>
          resources*: <...>
        }
        provisioning*: (string enum:MANAGED) Database provisioning strategy.
      }
    }
  }
}
```

Example:

```bash
kapten databases create-redis <project-id> <environment-id> <input.json
```

## kapten databases delete

Deletes a database, with the variables and secrets Kapten created for it.

```bash
kapten databases delete <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases delete <project-id> <environment-id> <database-id>
```

## kapten databases deploy

Starts a deployment of the database.

```bash
kapten databases deploy <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases deploy <project-id> <environment-id> <database-id>
```

## kapten databases get-mongodb

Returns a MongoDB database.

```bash
kapten databases get-mongodb <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases get-mongodb <project-id> <environment-id> <database-id>
```

## kapten databases get-mysql

Returns a MySQL database.

```bash
kapten databases get-mysql <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases get-mysql <project-id> <environment-id> <database-id>
```

## kapten databases get-postgresql

Returns a PostgreSQL database.

```bash
kapten databases get-postgresql <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases get-postgresql <project-id> <environment-id> <database-id>
```

## kapten databases get-redis

Returns a Redis database.

```bash
kapten databases get-redis <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

Example:

```bash
kapten databases get-redis <project-id> <environment-id> <database-id>
```

## kapten databases get-run

Returns one deployment run of the database.

```bash
kapten databases get-run <project-id> <environment-id> <database-id> <component-run-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `component-run-id` | The unique identifier for the component run |

Example:

```bash
kapten databases get-run <project-id> <environment-id> <database-id> <component-run-id>
```

## kapten databases list-runs

Returns the database's deployment runs, a page at a time.

```bash
kapten databases list-runs <project-id> <environment-id> <database-id> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |

| Flag | Description |
| --- | --- |
| `--action string` | Filter component runs by action. |
| `--created-after string` | Filter component runs created at or after this timestamp. |
| `--created-before string` | Filter component runs created at or before this timestamp. |
| `--page-limit int` | Maximum number of records to return (default: 10) |
| `--page-number int` | Page number (default: 1) |
| `--status string` | Filter component runs by deployment status. |
| `--trigger string` | Filter component runs by trigger source. |

Example:

```bash
kapten databases list-runs <project-id> <environment-id> <database-id>
```

## kapten databases query-run-logs

Returns the deployment logs of one database run: what Kapten did while deploying it, and what its agent on the cluster did. For the database's own output, use the component logs.

Without `from` or `to`, the window spans the run, from its start to its end. Logs follow the retention of the log backend, so the logs of an old run may be gone, and runs from before run logs existed return an empty list.

```bash
kapten databases query-run-logs <project-id> <environment-id> <database-id> <component-run-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `component-run-id` | The unique identifier for the component run |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
{
  from: (string format:date-time) Inclusive lower bound for the run log time range.
  levels: [
    (string)
  ]
  limit: (integer format:int32 default:200 min:1 max:1000) Maximum number of most recent raw backend records to query.
  source: [
    (string enum:control_plane,agent,builder)
  ]
  text: (string) Optional phrase to search in the log message.
  to: (string format:date-time) Inclusive upper bound for the run log time range.
  view: (string default:both enum:timeline,raw,both) Which run log projection to return.
}
```

Example:

```bash
kapten databases query-run-logs <project-id> <environment-id> <database-id> <component-run-id> 'limit: 200, source: [control_plane, agent], view: timeline'
```

## kapten databases update-mongodb

Updates a MongoDB database's settings. Its provisioning and `database_name` cannot change.

```bash
kapten databases update-mongodb <project-id> <environment-id> <database-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
{
  accessibility: allOf{
    (string enum:PRIVATE,PUBLIC) Database network accessibility.
  }
  configuration: {
    activate_backups: (boolean)
    activate_high_availability: (boolean)
    encrypt_disk: (boolean)
    resources: {
      cpu_limit_in_milli: (integer format:int64 min:0)
      cpu_request_in_milli: (integer format:int64 min:0)
      database_disk_iops: (integer format:int64 min:0)
      database_disk_type: (string)
      database_instance_tier: (string)
      disk_size_in_gib: (integer format:int64 min:0)
      ram_limit_in_mib: (integer format:int64 min:0)
      ram_request_in_mib: (integer format:int64 min:0)
    }
  }
  description: (string) Updated database description.
  name: (string pattern:\S minLen:1) Updated database name.
  version: (string) Updated database engine version.
}
```

Example:

```bash
kapten databases update-mongodb <project-id> <environment-id> <database-id> <input.json
```

## kapten databases update-mysql

Updates a MySQL database's settings. Its provisioning and `database_name` cannot change.

```bash
kapten databases update-mysql <project-id> <environment-id> <database-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
{
  accessibility: allOf{
    (string enum:PRIVATE,PUBLIC) Database network accessibility.
  }
  configuration: {
    activate_backups: (boolean)
    activate_high_availability: (boolean)
    encrypt_disk: (boolean)
    resources: {
      cpu_limit_in_milli: (integer format:int64 min:0)
      cpu_request_in_milli: (integer format:int64 min:0)
      database_disk_iops: (integer format:int64 min:0)
      database_disk_type: (string)
      database_instance_tier: (string)
      disk_size_in_gib: (integer format:int64 min:0)
      ram_limit_in_mib: (integer format:int64 min:0)
      ram_request_in_mib: (integer format:int64 min:0)
    }
  }
  description: (string) Updated database description.
  name: (string pattern:\S minLen:1) Updated database name.
  version: (string) Updated database engine version.
}
```

Example:

```bash
kapten databases update-mysql <project-id> <environment-id> <database-id> <input.json
```

## kapten databases update-postgresql

Updates a PostgreSQL database's settings. Its provisioning and `database_name` cannot change.

```bash
kapten databases update-postgresql <project-id> <environment-id> <database-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
{
  accessibility: allOf{
    (string enum:PRIVATE,PUBLIC) Database network accessibility.
  }
  configuration: {
    activate_backups: (boolean)
    activate_high_availability: (boolean)
    encrypt_disk: (boolean)
    resources: {
      cpu_limit_in_milli: (integer format:int64 min:0)
      cpu_request_in_milli: (integer format:int64 min:0)
      database_disk_iops: (integer format:int64 min:0)
      database_disk_type: (string)
      database_instance_tier: (string)
      disk_size_in_gib: (integer format:int64 min:0)
      ram_limit_in_mib: (integer format:int64 min:0)
      ram_request_in_mib: (integer format:int64 min:0)
    }
  }
  description: (string) Updated database description.
  name: (string pattern:\S minLen:1) Updated database name.
  version: (string) Updated database engine version.
}
```

Example:

```bash
kapten databases update-postgresql <project-id> <environment-id> <database-id> <input.json
```

## kapten databases update-redis

Updates a Redis database's settings. Its provisioning and `database_name` cannot change.

```bash
kapten databases update-redis <project-id> <environment-id> <database-id> <body...> [flags]
```

| Argument | Description |
| --- | --- |
| `project-id` | The unique identifier for the project |
| `environment-id` | The unique identifier of the environment |
| `database-id` | Unique identifier of the database. |
| `body...` | The request body, as shorthand or JSON. See [Request bodies](/cli/request-bodies). |

| Flag | Description |
| --- | --- |
| `--rsh-generate-body` | Print an example request body and exit |
| `--rsh-validate` | Validate the JSON request body against the OpenAPI schema before sending |

Request body fields, `*` for required:

```text
{
  accessibility: allOf{
    (string enum:PRIVATE,PUBLIC) Database network accessibility.
  }
  configuration: {
    activate_backups: (boolean)
    activate_high_availability: (boolean)
    encrypt_disk: (boolean)
    resources: {
      cpu_limit_in_milli: (integer format:int64 min:0)
      cpu_request_in_milli: (integer format:int64 min:0)
      database_disk_iops: (integer format:int64 min:0)
      database_disk_type: (string)
      database_instance_tier: (string)
      disk_size_in_gib: (integer format:int64 min:0)
      ram_limit_in_mib: (integer format:int64 min:0)
      ram_request_in_mib: (integer format:int64 min:0)
    }
  }
  description: (string) Updated database description.
  name: (string pattern:\S minLen:1) Updated database name.
  version: (string) Updated database engine version.
}
```

Example:

```bash
kapten databases update-redis <project-id> <environment-id> <database-id> <input.json
```
