# `mix phoenix_kit.repair`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.13.7/lib/mix/tasks/phoenix_kit.repair.ex#L1)

Verifies and additively repairs a PhoenixKit installation against the
generated `PhoenixKit.Migrations.ExpectedSchema` manifest (spec §6).

## Usage

    $ mix phoenix_kit.repair
    $ mix phoenix_kit.repair --dry-run
    $ mix phoenix_kit.repair --prefix=auth
    $ mix phoenix_kit.repair --json
    $ mix phoenix_kit.repair --adopt
    $ mix phoenix_kit.repair --heal-comment
    $ mix phoenix_kit.repair --unsafe-pooled

## Options

  * `--dry-run` — plan only; never writes (creates, backfills, comment
    changes). Every finding that would otherwise be `:repaired` reports
    as `:missing` instead. Equivalent in effect to `mix phoenix_kit.repair`
    always running the read-only half — the flag exists so the command
    name stays `repair` for the write path and `--dry-run` opts into the
    identical `verify/1` behavior without a separate subcommand.
  * `--prefix` — schema prefix. Resolved the same way
    `mix phoenix_kit.update`/`--status` resolve it: `--prefix` flag →
    `config :phoenix_kit, :prefix` → `"public"`
    (`PhoenixKit.Install.PrefixConfig.resolve_prefix/1`).
  * `--json` — machine-readable output (`PhoenixKit.Migrations.Repair.Report.to_json_map/1`)
    instead of the human-readable report.
  * `--adopt` — spec §6.4 R4. Only meaningful when the version comment is
    missing (half-installed/adopted/PgBouncer-stripped) — converges the
    floor-level slice and stamps the floor version iff it comes back
    clean.
  * `--heal-comment` — spec §6.4 R2. Only meaningful when the schema is
    structurally ahead of what the comment claims — stamps the highest
    version whose objects are all present.
  * `--unsafe-pooled` — required to proceed when a pooled connection
    (PgBouncer transaction-mode or similar) is detected; skips the
    advisory lock and FK `VALIDATE CONSTRAINT` (§6.3).

## Exit codes

    0  clean — nothing to report
    1  the manifest is not generated yet, OR repairs were applied/are pending
    2  a hard error (below-floor, above-current, concurrent migration,
       pooled connection without --unsafe-pooled, adopt-required without
       --adopt) OR report-only divergences are present in the findings

## Manifest not generated yet

`PhoenixKit.Migrations.ExpectedSchema` — the tool-generated manifest —
ships with this release, so the normal path is fully wired. The
not-generated branch remains for a checkout where the manifest has been
removed or replaced (`config :phoenix_kit, :expected_schema_module`):
every invocation then prints
`PhoenixKit.Migrations.ExpectedSchema.Resolver.not_generated_message/0`
and exits `1` rather than silently reporting a clean database.

---

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