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

Adds a publication workflow to a resource

Generates a publication resource that moves from `:draft` to `:scheduled`,
goes `:published` once its `publish_at` passes, and can be unpublished and
republished. The subject gains `has_one :publication` and a `published?`
calculation. When the subject does not exist, it is created with
`mix ash.gen.resource` first.

Nobody may create a publication until the application defines who can, in
the generated `Checks.CanCreate` module. Nobody may schedule, publish or
unpublish until it does the same in `Checks.CanPublish`.

## Example

```bash
mix ash_workflow.gen.publication MyApp.Blog.Post --with-unpublish-at
```

## Options

* `--module` - the publication resource's module name. Defaults to the
  subject's name with `Publication` appended.
* `--domain` - the domain for a subject the task creates. Required only
  when the subject does not exist.
* `--with-unpublish-at` - generates an `unpublish_at` attribute, set when
  scheduling or republishing, that moves a publication to `:unpublished`
  once it passes. Defaults to `false`.
* `--transition-log` - also generates a transition log for the publication
  with `mix ash_workflow.gen.transition_log`. Defaults to `true`.

---

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