# `MishkaBlog.Resources.Changes.PublishLifecycle`
[🔗](https://github.com/mishka-group/mishka_blog/blob/v0.0.1/lib/mishka_blog/resources/__changes/publish_lifecycle.ex#L5)

Keeps a post's publish times in step with its `:status`.

- A post whose status is `:published` and that has no `:published_at` gets the current time,
  truncated to the second.
- A post whose status is `:scheduled` and that has no `:scheduled_publish_at` is refused with an
  error on that field.
- Any other status is left alone.

On a create it applies to every post. On an update it applies only when the status is changing, so
saving an already published post never moves its `:published_at`.

## Usage

    create :create do
      change MishkaBlog.Resources.Changes.PublishLifecycle
    end

    update :update do
      change MishkaBlog.Resources.Changes.PublishLifecycle
    end

---

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