PhoenixKitBoards.Migrations (PhoenixKitBoards v0.2.0)

Copy Markdown View Source

Versioned migration coordinator for phoenix_kit_boards — the module returned from PhoenixKitBoards.migration_module/0.

mix phoenix_kit.update discovers this, compares migrated_version_runtime/1 (what's installed) with current_version/0 (what the code needs), and — when behind — generates a host migration whose up/0 calls up/1 here. So the host installs/updates the phoenix_kit_boards table with no hand-written migration, and it honors the host's --prefix (named-schema installs).

Version is tracked via a COMMENT ON TABLE on phoenix_kit_boards itself (mirroring core's own PhoenixKit.Migrations.Postgres and the pattern documented in phoenix_kit_hello_world's README "Versioned migrations" section) — not just a boolean "does the table exist", so a future V2 can tell "not installed" apart from "installed at V1".

Versions:

  • 0 — table absent (not installed)
  • 1phoenix_kit_boards table present, UUIDv7 primary key

Summary

Functions

The version this code expects the schema to be at.

Roll back. Migration-context only.

The version currently installed in the database — 0 if the table is absent, and also 0 if it exists but matches no version this module knows how to produce. up/1 raises with the details for that second case rather than migrating an unrecognised table blindly. Migration-context only — reads via Ecto.Migration.repo/0.

Runtime-safe version of migrated_version/1 — uses PhoenixKit's configured repo instead of the Ecto.Migration repo() helper, so it can be called from Mix tasks and other non-migration contexts (mix phoenix_kit.update).

Run migrations up to (and including) the target version. Migration-context only.

Functions

current_version()

@spec current_version() :: pos_integer()

The version this code expects the schema to be at.

down(opts \\ [])

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

Roll back. Migration-context only.

migrated_version(opts \\ [])

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

The version currently installed in the database — 0 if the table is absent, and also 0 if it exists but matches no version this module knows how to produce. up/1 raises with the details for that second case rather than migrating an unrecognised table blindly. Migration-context only — reads via Ecto.Migration.repo/0.

migrated_version_runtime(opts \\ [])

@spec migrated_version_runtime(keyword()) :: non_neg_integer()

Runtime-safe version of migrated_version/1 — uses PhoenixKit's configured repo instead of the Ecto.Migration repo() helper, so it can be called from Mix tasks and other non-migration contexts (mix phoenix_kit.update).

up(opts \\ [])

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

Run migrations up to (and including) the target version. Migration-context only.