GeoGenius.Migration (geo_genius v0.2.0)

Copy Markdown View Source

Versioned GeoGenius schema migrations for host applications.

Host migrations pin both the target version and the PostgreSQL prefix.

Summary

Functions

Inspects an installed schema's version, contract marker, signatures, and capabilities.

Returns the content-addressed identity of the schema contract shipped by this package.

Returns the current migration version supported by this library.

Rolls back migrations to the target version.

Returns the installed GeoGenius schema version for prefix, read directly through repo.

Returns the currently migrated version from the database.

Renders a deterministic SQL transition for hosts that do not run Ecto migrations.

Returns the explicit capabilities required by the current schema contract.

Applies migrations up to the target version.

Functions

contract_status(repo, prefix)

@spec contract_status(module(), String.t()) :: map()

Inspects an installed schema's version, contract marker, signatures, and capabilities.

current_contract_revision()

@spec current_contract_revision() :: String.t()

Returns the content-addressed identity of the schema contract shipped by this package.

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 "geo_genius".
  • :version - Target version to roll back to. Defaults to 0.

installed_version(repo, prefix)

@spec installed_version(module(), String.t()) :: non_neg_integer()

Returns the installed GeoGenius schema version for prefix, read directly through repo.

Unlike migrated_version/1 (usable only from inside an active Ecto.Migration run, since it resolves its repo from the migration process), this takes an explicit repo and works from ordinary application or mix task code.

Returns 0 if GeoGenius has not been installed at prefix.

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.

render_sql(opts)

@spec render_sql(keyword()) :: String.t()

Renders a deterministic SQL transition for hosts that do not run Ecto migrations.

required_capabilities()

@spec required_capabilities() :: [String.t()]

Returns the explicit capabilities required by the current schema contract.

up(opts \\ [])

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

Applies migrations up to the target version.

Options

  • :prefix - Schema prefix. Defaults to "geo_genius".
  • :version - Target version. Defaults to 2.