# `Foresight.Migrations`
[🔗](https://github.com/fosferon/foresight/blob/v0.3.2/lib/foresight/migrations.ex#L1)

Installs Foresight's shared control-plane schema into a consumer database.

`install/2` accepts the consumer's Repo module and runs only the packaged
control-plane migrations. Tenant data migrations are deliberately excluded;
use `Foresight.Tenancy.provision_mode_c_schema/4` for a Mode C tenant schema.

Foresight records these migrations in `foresight_schema_migrations`, not the
host application's `schema_migrations` table. The separate ledger prevents a
host migration with the same integer version from being mistaken for a
Foresight migration.

# `install`

```elixir
@spec install(
  module(),
  keyword()
) :: {:ok, %{migrated_versions: [integer()]}} | {:error, term()}
```

Installs or upgrades Foresight control-plane tables in `repo`.

The migration source is always the copy packaged with the running Foresight
application (`priv/repo/migrations`). The operation is idempotent and returns
only versions applied by this invocation:

    {:ok, %{migrated_versions: versions}}

`:log` and `:log_migrator_sql` are forwarded to Ecto's migrator. Errors are
returned as `{:error, reason}`. A manifest mismatch or a changed filename/content
for an already-applied version fails closed.

# `migrations_path`

```elixir
@spec migrations_path() :: String.t()
```

Returns the absolute packaged migration directory used by `install/2`.

---

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