# `MishkaCmsCore.Dev.HistorySeeds`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/dev/history_seeds.ex#L5)

Fills a page's editing history with every state the timeline can draw, so the whole sheet can be
looked at without waiting months for the awkward ones to occur naturally.

Two of these states cannot be produced by using the editor at all today:

  * an **assistant** row — `MishkaCmsCore.Runtime.PageBuilder.AiBackend` has no model configured,
    and its `Echo` default deliberately makes no edits rather than pretending to;
  * a **payload dropped** row — that is what retention does to a document after months, or after
    500 changes.

Everything is written through the resource's own actions rather than SQL, so the policies, the
validations and the `site_id` rule all run exactly as they do in the editor. A seed that skipped
them would be a seed that proves nothing.

Run it from an `iex -S mix` session:

    MishkaCmsCore.Dev.HistorySeeds.seed_all()          # every page on every site
    MishkaCmsCore.Dev.HistorySeeds.seed(page_id)       # one page
    MishkaCmsCore.Dev.HistorySeeds.clear_all()         # take it all back out

Development only. It is not called from the application's own seeds.

# `clear_all`

```elixir
@spec clear_all() :: {:ok, non_neg_integer()}
```

Remove every seeded row and the snapshots behind them.

# `seed`

```elixir
@spec seed(String.t()) :: {:ok, non_neg_integer()} | {:error, term()}
```

Seed one page by id, with the ordinary edits that make it worth paging through.

# `seed_all`

```elixir
@spec seed_all(keyword()) :: {:ok, non_neg_integer()}
```

Seed every active page with a full timeline. Returns how many rows were written.

`full:` names one page that additionally gets enough ordinary edits to fill several pages of the
sheet — that is the page to test paging and the note spoiler on. Every other page gets the ten
states, which is what the states are for.

---

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