# `Masu.History.Ecto`
[🔗](https://github.com/hattoriai/masu/blob/v0.7.0/lib/masu/history/ecto.ex#L2)

The history of grids in a table of any Ecto repo (see `Masu.History`):
the grid's own, or one of its own, in another database.

    defmodule MyApp.GridHistory do
      use Masu.History.Ecto, repo: MyApp.Repo
    end

    # In a SQLite file of its own, next to the app's PostgreSQL:
    defmodule MyApp.GridHistory do
      use Masu.History.Ecto, repo: MyApp.HistoryRepo
    end

    <.data_grid id="orders" ... history={MyApp.GridHistory} user={@user}>

`mix masu.gen.history` writes the migration of the table,
`masu_history` (`--migrations-path` for another repo's). Options of
`use`: `repo` (required), and `table`, for a table of another name.

An entry is a row: `grid`, `row` (the row's id, as text), `key` (nil
for a row's own entry), `op`, `user_id`, `user_name`, `origin`,
`batch`, `data` (a map: the row's id, and the values before and
after) and `inserted_at`. The table has indexes on `grid` with `row`
and `key`, and on `batch`. It runs on PostgreSQL, MySQL and SQLite.

---

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