# `mix ash_vault.verify`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/mix/tasks/ash_vault.verify.ex#L1)

Verify a backfill: decrypt a sample of rows and compare them to the plaintext column
they were encrypted from.

Run this between *backfill* and *cut over*. Cutting over is the irreversible step of
the migration, so it should follow a clean verify — after it, the plaintext column is
no longer written and the only copy of the data is the ciphertext.

This task writes nothing and mints no key material beyond what decryption needs.

## Usage

    mix ash_vault.verify MyApp.Accounts.User email --tenant acme
    mix ash_vault.verify MyApp.Accounts.User email --from legacy_email --sample 0
    mix ash_vault.verify MyApp.Accounts.User email --all-tenants MyApp.Accounts.list_tenant_ids/0

## Options

    --from ATTR          plaintext column to compare against (default: `backfill_from`)
    --tenant TENANT      required when the key scope is `:tenant`
    --all-tenants MFA    zero-arity `Module.function/0` listing tenants
    --domain MODULE      Ash domain (inferred from `:ash_domains` when omitted)
    --batch-size N       rows per read (default 500)
    --sample N           rows to decrypt; `0` checks every row. Default: 10% of the
                         table or 1000 rows, whichever is smaller, always including the
                         first and the last row.

## Exit status

Non-zero on the first tenant with any mismatch — a row whose ciphertext is NULL, whose
plaintext differs, or which fails to decrypt at all. The summary names the offending
primary keys.

    ash_vault.verify=result resource=MyApp.Accounts.User field=email rows=2000 checked=200 mismatches=0
    Verified 200 of 2000 row(s) of MyApp.Accounts.User.email: no mismatches.

---

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