Lockspire.Install.Migrations (lockspire v1.6.1)

Copy Markdown

Safely plans and applies Lockspire's packaged Ecto migrations to a host project.

Planning is read-only: it validates the complete packaged and host inventories before reporting any file that can be copied. Applying an approved plan copies only files that were absent during preflight and never overwrites a host-owned migration.

Summary

Functions

Copies only the missing files from a successful plan/1 result.

Returns a complete, read-only copy plan for packaged migrations.

Types

operation()

@type operation() :: %{
  status: operation_status(),
  source: String.t(),
  destination: String.t(),
  version: String.t(),
  name: String.t(),
  relative_path: String.t(),
  checksum: String.t()
}

operation_status()

@type operation_status() :: :copy | :unchanged

plan()

@type plan() :: %{
  source_root: String.t(),
  destination_root: String.t(),
  operations: [operation()]
}

Functions

apply(approved_plan)

@spec apply(plan()) ::
  {:ok, %{operations: [map()], migrations: [map()]}} | {:error, [map()]}

Copies only the missing files from a successful plan/1 result.

Before making the destination directory, application confirms that both source and destination inventory still match the approved plan. This preserves the host's no-overwrite guarantee if files change between preflight and apply.

plan(opts \\ [])

@spec plan(keyword()) :: {:ok, plan()} | {:error, [map()]}

Returns a complete, read-only copy plan for packaged migrations.

:source_root and :project_root are injectable for tests. In normal use they default to Lockspire's packaged migrations and the current Mix project.