Usher.Migration (Usher v0.3.0)
View SourceMigration 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_version("v03")
end
endFor existing installations upgrading:
defmodule MyApp.Repo.Migrations.UpgradeUsherInvitations do
use Ecto.Migration
import Usher.Migration
def change do
migrate_to_version("v03")
end
end
Summary
Functions
Returns a list of all available migration versions.
Returns the latest version of the Usher migrations.
Migrates the Usher tables to the latest version.
Migrates the Usher tables to a specific version.
Functions
@spec all_versions() :: [String.t()]
Returns a list of all available migration versions.
@spec latest_version() :: String.t()
Returns the latest version of the Usher migrations.
Migrates the Usher tables to the latest version.
This function is deprecated because it cannot be used more than once
in your migration files. Use migrate_to_version/1 instead to specify
the exact version you want to migrate to.
See the CHANGELOG for details on breaking changes.
Migrates the Usher tables to a specific 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.
Parameters
version: The target version to migrate to, e.g. "v01", "v02", etc.
Examples
migrate_to_version("v03")