# `PeriodicalEcto.Migration`
[🔗](https://github.com/joetjen/periodical_ecto/blob/main/lib/periodical_ecto/migration.ex#L1)

Creates and drops the claims table. Call it from one of your migrations:

    defmodule MyApp.Repo.Migrations.AddPeriodicalClaims do
      use Ecto.Migration

      def up, do: PeriodicalEcto.Migration.up()
      def down, do: PeriodicalEcto.Migration.down()
    end

Both take `:table` and `:prefix`, matching the coordinator's options when
those are not the defaults:

    def up, do: PeriodicalEcto.Migration.up(table: "scheduler_claims", prefix: "ops")

The table:

| Column | Type | Purpose |
| --- | --- | --- |
| `key` | `varchar(64)`, primary key | `Periodical.Coordinator.key/1` of the schedule name |
| `name` | `varchar(255)` | The schedule name, for people reading the table |
| `token` | `varchar(64)` | The claim holding the lease |
| `scheduled_at` | UTC timestamp, microseconds | The occurrence the holder claimed |
| `expires_at` | UTC timestamp, microseconds, indexed | When the lease ends, by the database clock |

# `down`

```elixir
@spec down(keyword()) :: :ok
```

Drops the claims table.

# `up`

```elixir
@spec up(keyword()) :: :ok
```

Creates the claims table and its expiry index.

---

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