PhoenixKitManufacturing.Migrations.Machines (PhoenixKitManufacturing v0.2.0)

Copy Markdown View Source

Versioned migration for the Manufacturing module.

Creates the machines reference-book tables:

  • phoenix_kit_machines
  • phoenix_kit_machine_types
  • phoenix_kit_machine_type_assignments (join)

All statements use IF NOT EXISTS guards — safe to run multiple times.

Implements the versioned-migration protocol expected by PhoenixKit Core (mix phoenix_kit.update): current_version/0 and migrated_version_runtime/1. The host applies these by running mix phoenix_kit.update, which discovers this module via PhoenixKitManufacturing.migration_module/0, diffs the applied version against current_version/0, and generates + runs a wrapper migration. Reference implementation — PhoenixKit.Migrations.Postgres in Core.

Depends on uuid_generate_v7(), provided by core's early migrations.

Summary

Functions

Target schema version of the Manufacturing module.

Rolls back the Manufacturing module migration. Accepts a keyword list or map.

Currently applied schema version, read from the database.

Applies the Manufacturing module migration. Accepts a keyword list or map.

Functions

current_version()

@spec current_version() :: pos_integer()

Target schema version of the Manufacturing module.

down(opts \\ [])

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

Rolls back the Manufacturing module migration. Accepts a keyword list or map.

migrated_version_runtime(opts \\ [])

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

Currently applied schema version, read from the database.

Returns 0 when the phoenix_kit_machines table does not yet exist, and 1 once it has been created. opts is a keyword list with an optional :prefix.

up(opts \\ [])

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

Applies the Manufacturing module migration. Accepts a keyword list or map.