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

Cryptographically erase an AshVault scope.

> #### This is irreversible {: .error}
>
> Every value ever encrypted under the scope becomes permanently unrecoverable. There
> is no undo, no backup of the key, and no support ticket that brings it back. The
> provider writes a **tombstone**, so the scope can never be re-minted either —
> silently re-minting would turn crypto-erasure into silent data loss.

## Usage

    mix ash_vault.destroy_keys MyApp.Accounts.User --tenant acme

The task prints the scope, every resource and field that is about to become
undecryptable, and the current key version. It then asks you to **type the scope name
back**. `--yes` does not skip that prompt, and there is deliberately no `--force`: a
deploy script cannot destroy a tenant's data by passing one more flag.

In `MIX_ENV=prod` it additionally refuses to run unless `MIX_ENV` was passed explicitly
or `--i-know-what-this-does` is given.

## Options

    --tenant TENANT            required when the key scope is `:tenant`
    --domain MODULE            Ash domain (inferred from `:ash_domains` when omitted)
    --i-know-what-this-does    required in production
    --yes                      skips *other* confirmations; never the scope prompt

## Idempotence

Destroying an already-destroyed scope prints `status=already_destroyed` and exits 0. It
does not prompt, because there is nothing left to lose.

## Output

    ash_vault.destroy_keys=target resource=MyApp.Accounts.User tenant=acme scope=acme \
      vault=MyApp.Vault provider=MyApp.KeyProvider status=active version=3 fields=4
    undecryptable=MyApp.Accounts.User.email
    undecryptable=MyApp.Accounts.User.ssn
    ash_vault.destroy_keys=done scope=acme versions_destroyed=3 tombstone=confirmed
    DESTROYED MyApp.Vault scope acme: 3 key version(s), 4 field(s) across 2 resource(s).

The tombstone is re-read from the provider before success is reported: if the provider
does not answer `{:error, :destroyed}` afterwards, the task exits non-zero rather than
claiming an erasure that did not happen.

---

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