Adds a dormancy workflow to a resource
Generates a dormancy resource that moves to :dormant once its
last_activity_at is older than --dormant-after, and back to :active
when it is reactivated. The subject gains has_one :dormancy, a
dormant? calculation, and a changes block that runs the generated
Changes.StartDormancy on every create, so each new subject gets a
dormancy. Subjects created before the task ran need a backfill. When the
subject does not exist, it is created with mix ash.gen.resource first.
The application decides what counts as activity, by adding the generated
Changes.RecordActivity to subject actions or by calling the dormancy's
record_activity action.
Nobody may create a dormancy directly or reactivate one until the
application defines who can, in the generated Checks.CanCreate and
Checks.CanReactivate modules. Changes.StartDormancy does not consult
Checks.CanCreate.
Example
mix ash_workflow.gen.dormancy MyApp.Accounts.Account --dormant-after 90d --archive-after 180d
Options
--dormant-after- moves a dormancy to:dormantoncelast_activity_atis this old, given as30m,12h,2dor2w. A duration under a minute needsAshWorkflow.Scheduler.Precise. Required.--archive-after- moves a dormancy to:archivedonce it has been:dormantthis long. Without it, no:archivedstep is generated. A duration under a minute needsAshWorkflow.Scheduler.Precise.--module- the dormancy resource's module name. Defaults to the subject's name withDormancyappended.--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 dormancy withmix ash_workflow.gen.transition_log. Defaults totrue.