GoodAnalytics.Migration (GoodAnalytics v0.1.1)

Copy Markdown View Source

Manages database migrations for GoodAnalytics tables.

Uses EctoEvolver for versioned, library-owned PostgreSQL migrations. All tables live in the good_analytics schema with ga_ prefix.

Usage in Host App

Generate an Ecto migration in your host application:

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

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

Or use the Mix task:

mix good_analytics.setup

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 "good_analytics".
  • :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 "good_analytics".
  • :version - Target version. Defaults to 13.