PgFlowDashboard.Migration (PgFlow v0.1.0)

Copy Markdown View Source

Manages PgFlowDashboard database migrations with version tracking.

This module provides versioned migrations for PgFlowDashboard, allowing incremental upgrades and rollbacks.

Usage in Ecto Migrations

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

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

Options

  • :prefix - The schema prefix to use. Defaults to "pgflow_dashboard".
  • :version - Target version for up/down migrations. Defaults to current/0.

Version Tracking

Versions are tracked via PostgreSQL comments on the runs_with_progress view:

COMMENT ON VIEW schema.runs_with_progress IS 'PgFlowDashboard version=1';

Summary

Functions

Returns the current migration version supported by this library.

Rolls back migrations to the target version.

Returns the currently migrated version from the database.

Applies migrations up to the target version.

Functions

current_version()

@spec current_version() :: pos_integer()

Returns the current migration version supported by this library.

down(opts \\ [])

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

Rolls back migrations to the target version.

Options

  • :prefix - Schema prefix. Defaults to "pgflow_dashboard".
  • :version - Target version to roll back to. Defaults to 0.

migrated_version(opts \\ [])

@spec migrated_version(keyword()) :: non_neg_integer()

Returns the currently migrated version from the database.

Returns 0 if no migrations have been applied.

up(opts \\ [])

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

Applies migrations up to the target version.

Options

  • :prefix - Schema prefix. Defaults to "pgflow_dashboard".
  • :version - Target version. Defaults to 1.