# `mix ash_workflow.gen.deletion`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/mix/tasks/ash_workflow.gen.deletion.ex#L55)

Adds a deletion workflow to a resource

Generates a deletion resource that waits a grace period after a deletion
is requested, then runs a `:purge` action and moves to `:deleted`. A
request can be restored during the grace period. The subject gains
`has_one :deletion` and a `pending_deletion?` calculation. When the
subject does not exist, it is created with `mix ash.gen.resource` first.

Every purge fails until the application defines what it erases, in the
generated `Changes.Purge` module. Nobody may request a deletion, request
it again, retry a purge or restore a deletion until the application
defines who can, in the generated `Checks.CanRequest` and
`Checks.CanRestore` modules.

## Example

```bash
mix ash_workflow.gen.deletion MyApp.Accounts.Account --grace-period 30d
```

## Options

* `--grace-period` - required. How long a request waits before the purge
  runs, given as `30m`, `12h`, `2d` or `2w`. A duration under a minute
  needs `AshWorkflow.Scheduler.Precise`.
* `--max-attempts` - how many times the purge runs before the deletion
  moves to `:purge_failed`. Defaults to `3`. With `1`, no `retry` block is
  generated.
* `--module` - the deletion resource's module name. Defaults to the
  subject's name with `Deletion` appended.
* `--domain` - the domain for a subject the task creates. Required only
  when the subject does not exist.
* `--transition-log` - also generates a transition log for the deletion
  with `mix ash_workflow.gen.transition_log`. Defaults to `true`.

---

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