# `Lockspire.Install.Migrations`

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.

# `operation`

```elixir
@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`

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

# `plan`

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

# `apply`

```elixir
@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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
