# `EctoFoundationDB.CLI`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L1)

This module provides functions that are to be run by an operator, and not
part of application code.

# `copy_field!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L125)

For each schema item in the database, copies the contents of one field to another.

## Arguments

- `repo`: The repository to use.
- `schema`: The schema to copy from.
- `from`: The field to copy from.
- `to`: The field to copy to.
- `options`: Options for the operation.

## Requirements

- Both fields must exist on the Schema.

## Options

- `:prefix`: If provided, only this tenant will be processed. If not provided, then all tenants concurrently.
- `:max_rows`: Maximum number of items to process in a single transaction.

Also supports options from `run_concurrently_for_all_tenants!/3` and `EctoFoundationDB.Tenant.open/3`.

# `copy_fields!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L149)

For each schema item in the database, copies the contents of a set of fields to another set of fields.

## Arguments

- `repo`: The repository to use.
- `schema`: The schema to copy from.
- `copies`: A Keyword list of fields to copy from and to.
- `options`: Options for the operation.

## Requirements

- All fields must exist on the Schema.

## Options

- `:prefix`: If provided, only this tenant will be processed. If not provided, then all tenants concurrently.
- `:max_rows`: Maximum number of items to process in a single transaction.

Also supports options from `run_concurrently_for_all_tenants!/3` and `EctoFoundationDB.Tenant.open/3`.

# `delete_field!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L205)

For each schema item in the database, deletes the given field.

## Arguments

- `repo`: The repository to use.
- `schema`: The schema to copy from.
- `field`: The field to delete.
- `options`: Options for the operation.

## Requirements

- The field must not exist on the Schema.
- The field must not be used in any registered metadata (indexes).

## Options

- `:prefix`: If provided, only this tenant will be processed. If not provided, then all tenants concurrently.
- `:max_rows`: Maximum number of items to process in a single transaction.

Also supports options from `run_concurrently_for_all_tenants!/3` and `EctoFoundationDB.Tenant.open/3`.

# `delete_fields!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L231)

For each schema item in the database, deletes the given fields.

## Arguments

- `repo`: The repository to use.
- `schema`: The schema to copy from.
- `fields`: The list of fields to delete.
- `options`: Options for the operation.

## Requirements

- Each field must not exist on the Schema.
- Each field must not be used in any registered metadata (indexes).

## Options

- `:prefix`: If provided, only this tenant will be processed. If not provided, then all tenants concurrently.
- `:max_rows`: Maximum number of items to process in a single transaction.

Also supports options from `run_concurrently_for_all_tenants!/3` and `EctoFoundationDB.Tenant.open/3`.

# `migrate!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L71)

Ensures all tenants in the database are migrated to the latest version.

## Arguments

- `repo`: The repository to use.
- `options`: Options to pass to the migration function.

## Options

- `:prefix`: If provided, only this tenant will be migrated. If not provided, then all tenants concurrently.

Also supports options from `run_concurrently_for_all_tenants!/3` and `EctoFoundationDB.Tenant.open/3`.

# `run_concurrently_for_all_tenants!`
[🔗](https://github.com/foundationdb-beam/ecto_foundationdb/blob/main/lib/ecto_foundationdb/cli.ex#L32)

Runs the provided 1-arity function for each tenant in the database concurrently.

## Arguments

- `repo`: The Ecto repository to use.
- `caller_fun`: A 1-arity function; the argument is the tenant.
- `options`: Optional keyword list of options.

## Options

- `:async_stream_options`: Options to be passed to `Task.async_stream/3`. Defaults to `ordered: false, max_concurrency: System.schedulers_online() * 2, timeout: :infinity`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
