PeriodicalEcto.Migration (PeriodicalEcto v0.1.0)

Copy Markdown View Source

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:

ColumnTypePurpose
keyvarchar(64), primary keyPeriodical.Coordinator.key/1 of the schedule name
namevarchar(255)The schedule name, for people reading the table
tokenvarchar(64)The claim holding the lease
scheduled_atUTC timestamp, microsecondsThe occurrence the holder claimed
expires_atUTC timestamp, microseconds, indexedWhen the lease ends, by the database clock

Summary

Functions

Drops the claims table.

Creates the claims table and its expiry index.

Functions

down(options \\ [])

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

Drops the claims table.

up(options \\ [])

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

Creates the claims table and its expiry index.