# `mix threadline.install`
[🔗](https://github.com/szTheory/threadline/blob/v1.2.0/lib/mix/tasks/threadline.install.ex#L1)

Generates an Ecto migration file for the Threadline audit schema.

## Usage

```sh
mix threadline.install
mix threadline.install --migrations-path priv/audit/migrations
mix threadline.install --repo MyApp.AuditRepo
```

## Options

- `--migrations-path PATH` — write the migrations to `PATH`, used as given and relative to the current directory. The repo is not loaded.
- `--repo REPO` / `-r REPO` — the Ecto repo whose migrations directory to use. Give it once: Threadline's audit tables live in one repo.

Without either option the directory is the first repo in your app's
`:ecto_repos`: its `:priv` setting joined with `migrations`, or
`priv/<repo name>/migrations` when `:priv` is unset. With no repo
configured it is `priv/repo/migrations`. A configured repo that cannot be
loaded also falls back to `priv/repo/migrations`, with a warning naming it.

Unknown flags raise an error instead of being ignored. Positional arguments
are ignored, so choose a directory or repo only with `--migrations-path` or
`--repo`.

In an umbrella, run the task from the child app's directory.

The generated migration creates the `audit_transactions` and `audit_changes`
tables plus the `threadline_capture_changes()` PL/pgSQL trigger function.

Run `mix ecto.migrate` after generation to apply the migration.

Running the task a second time prints a warning and exits without overwriting.

---

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