# `PhoenixMountable.Migration.Helpers`
[🔗](https://github.com/hattoriai/phoenix_mountable/blob/v0.2.1/lib/phoenix_mountable/migration.ex#L167)

Functions imported in `PhoenixMountable.Migration` modules.

# `add_column_if_missing`

Adds a column to a table unless it exists, on every adapter (MySQL has no
`ADD COLUMN IF NOT EXISTS`).

    add_column_if_missing(ctx, :my_lib_items, :slug, :string)

# `backfill`

Registers or runs a backfill. See `PhoenixMountable.Backfill`.

# `column_exists?`

Whether a column exists in a table of the context's prefix.

# `create_concurrently`

Creates an index without locking writes on Postgres (`CREATE INDEX
CONCURRENTLY`), and normally on other databases.

A version using it runs outside a transaction on Postgres. The generator
adds `@disable_ddl_transaction true` and `@disable_migration_lock true` to
the host's migration for it.

# `create_index_if_missing`

Creates an index unless one with its name exists, on every adapter.

MySQL has no `CREATE INDEX IF NOT EXISTS`, so Ecto's `create_if_not_exists`
raises there. This checks first, which keeps a version safe to run again
after a partial failure (MySQL DDL is not transactional).

# `drop_concurrently`

Drops an index if it exists, without locking writes on Postgres. See
`create_concurrently/1`.

# `drop_index_if_present`

Drops an index if one with its name exists, on every adapter.

# `key_type`

The column type of a foreign key to a library table: `:binary_id` or
`:bigint`, matching `primary_key/1`.

    add :item_id, references(:my_lib_items, type: key_type(ctx), prefix: ctx.prefix)

# `primary_key`

The primary key options chosen at install time, for library tables:

    create table(:my_lib_items, primary_key: primary_key(ctx), prefix: ctx.prefix)

`[name: :id, type: :binary_id]` when installed with `primary_key:
:binary_id`, otherwise `[name: :id, type: :bigserial]`.

# `rebuild_table`

Recreates a SQLite table with changed columns, keeping every column, index
and trigger the host added. See `PhoenixMountable.Migrations.SQLite`.

# `table_exists?`

Whether a table exists in the context's prefix.

---

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