Usher.Migration (Usher v0.2.0)

View Source

Migration helpers for creating and upgrading Usher tables.

Use this module in your application's migrations to create the necessary database tables for Usher.

Versioned Migrations

Starting with v0.2.0, Usher supports versioned migrations to allow incremental updates to the database schema. This is useful for existing installations that need to upgrade to new versions without losing data.

For new installations:

defmodule MyApp.Repo.Migrations.CreateUsherInvitations do
  use Ecto.Migration
  import Usher.Migration

  def change do
    migrate_to_latest()
  end
end

For existing installations upgrading:

defmodule MyApp.Repo.Migrations.UpgradeUsherInvitations do
  use Ecto.Migration
  import Usher.Migration

  def change do
    migrate_to_latest()
  end
end

The migrate_to_latest/1 function will automatically detect the current version and apply only the necessary migrations to reach the latest version.

Summary

Functions

Migrates the Usher tables to the latest version.

Functions

migrate_to_latest(opts \\ [])

Migrates the Usher tables to the latest version.

This function automatically detects the current migration version and applies only the necessary migrations to reach the latest version. It's safe to run multiple times.

Options

  • :table_name - Custom table name (defaults to configured table name)
  • :prefix - Schema prefix for the table

Examples

# Migrate to latest with defaults
migrate_to_latest()

# Migrate with custom options
migrate_to_latest(table_name: "my_invitations", prefix: "public")