PhoenixKit.Install.Common (phoenix_kit v1.4.4)

View Source

Common utilities shared between PhoenixKit installation and update tasks.

This module provides shared functionality for:

  • Timestamp generation
  • Version formatting
  • Status checking
  • Migration detection

Summary

Functions

Checks the current installation status for a given prefix.

Checks if an update is needed from current to target version.

Gets current PhoenixKit version from migrations system.

Describes what changed between versions.

Finds existing PhoenixKit migrations in the project.

Generates timestamp in Ecto migration format.

Gets migrated version for given prefix.

Pads a number with leading zero if less than 10.

Pads version number for consistent naming.

Checks if a filename matches PhoenixKit migration pattern.

Functions

check_installation_status(prefix \\ "public")

Checks the current installation status for a given prefix.

Returns one of:

  • {:not_installed} - PhoenixKit is not installed
  • {:current_version, version} - PhoenixKit is installed with given version

Parameters

  • prefix - Database schema prefix (default: "public")

Examples

iex> PhoenixKit.Install.Common.check_installation_status("public")
{:current_version, 3}

iex> PhoenixKit.Install.Common.check_installation_status("auth")
{:not_installed}

check_update_needed(prefix \\ "public", force \\ false)

Checks if an update is needed from current to target version.

Parameters

  • prefix - Database schema prefix
  • force - Force update even if already up to date

Returns

  • {:up_to_date, current_version} - Already up to date
  • {:update_needed, current_version, target_version} - Update available
  • {:not_installed} - PhoenixKit not installed

current_version()

Gets current PhoenixKit version from migrations system.

describe_version_changes(from_version, to_version)

Describes what changed between versions.

Parameters

  • from_version - Starting version number
  • to_version - Target version number

Returns

String describing the changes between versions.

find_existing_phoenix_kit_migrations()

Finds existing PhoenixKit migrations in the project.

Returns a list of migration file paths.

generate_timestamp()

Generates timestamp in Ecto migration format.

Examples

iex> PhoenixKit.Install.Common.generate_timestamp()
"20250908123045"

migrated_version(prefix \\ "public")

Gets migrated version for given prefix.

Parameters

  • prefix - Database schema prefix

pad(i)

Pads a number with leading zero if less than 10.

Examples

iex> PhoenixKit.Install.Common.pad(5)
"05"

iex> PhoenixKit.Install.Common.pad(12)
"12"

pad_version(version)

Pads version number for consistent naming.

Examples

iex> PhoenixKit.Install.Common.pad_version(1)
"01"

iex> PhoenixKit.Install.Common.pad_version(15)
"15"

phoenix_kit_migration?(filename)

Checks if a filename matches PhoenixKit migration pattern.

Examples

iex> PhoenixKit.Install.Common.phoenix_kit_migration?("20250908_add_phoenix_kit_tables.exs")
true

iex> PhoenixKit.Install.Common.phoenix_kit_migration?("20250908_create_users.exs")
false