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

Mint a new key version for a scope.

Rotation is **not** destructive: every existing value keeps decrypting with the key
version recorded in its envelope, and only new writes use the new version. Nothing
needs re-encrypting; if you want old rows on the new key, re-save them.

## Usage

    mix ash_vault.rotate MyApp.Accounts.User --tenant acme
    mix ash_vault.rotate MyApp.Accounts.User --all-tenants MyApp.Accounts.list_tenant_ids/0 --yes
    mix ash_vault.rotate MyApp.Notes                 # a `scope :global` resource

## Options

    --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)
    --yes                skip the confirmation prompt

## Output

    ash_vault.rotate=done resource=MyApp.Accounts.User tenant=acme scope=acme \
      vault=MyApp.Vault provider=MyApp.KeyProvider old_version=2 new_version=3
    Rotated MyApp.Vault scope acme: key version 2 -> 3.

Rotating a destroyed scope is an error and exits non-zero: the tombstone is permanent
and re-minting would turn crypto-erasure into silent data loss.

---

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