PhoenixFlags.Migration (PhoenixFlags v0.9.0)

Copy Markdown View Source

Migrations for PhoenixFlags.

Usage

Generate a migration in your app:

mix ecto.gen.migration add_system_flags

Then call the migration helpers:

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

  def up, do: PhoenixFlags.Migration.up()
  def down, do: PhoenixFlags.Migration.down(version: 1)
end

When the package releases a new version with schema changes, generate another migration and specify the target version:

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

  def up, do: PhoenixFlags.Migration.up(version: 2)
  def down, do: PhoenixFlags.Migration.down(version: 2)
end

Options

  • :version — target version to migrate to (default: latest)
  • :prefix — PostgreSQL schema prefix (default: "public")

Summary

Functions

Rolls back migrations to the specified version (or removes everything).

Returns the current migrated version.

Runs migrations up to the specified version (or the latest).

Functions

down(opts \\ [])

Rolls back migrations to the specified version (or removes everything).

migrated_version(prefix \\ "public")

Returns the current migrated version.

Reads the system_flags_meta table (V3+), falling back to the system_flags table comment used by older versions. Returns 0 if the tables don't exist or no version is recorded.

up(opts \\ [])

Runs migrations up to the specified version (or the latest).