Presubmit.Adapters.EctoMigration (presubmit v0.2.2)

Copy Markdown View Source

Models use Ecto.Migration modules as a list of schema operations.

Recognised shapes inside change/0, up/0, and down/0: create table, create_if_not_exists table, alter table (with add, remove, modify), drop table, create index/create_if_not_exists index (also unique_index), drop index, rename, and execute.

Summary

Types

One schema operation. Table and index names are atoms or strings as written.

t()

Functions

Columns added to table by this migration, from create table and alter table ... add.

Whether the migration can be rolled back: it defines up and down, or a change whose execute calls all carry a down statement.

The timestamp prefix of a migration filename, or nil.

Types

op()

@type op() ::
  {:create_table, atom() | String.t(),
   [%{name: atom(), type: term(), opts: keyword()}]}
  | {:alter_table, atom() | String.t(),
     [
       {:add, atom(), term(), keyword()}
       | {:remove, atom()}
       | {:modify, atom(), term(), keyword()}
     ]}
  | {:drop_table, atom() | String.t()}
  | {:create_index, atom() | String.t(), [atom()], keyword()}
  | {:drop_index, atom() | String.t(), keyword()}
  | {:rename, term()}
  | {:execute, :reversible | :irreversible}

One schema operation. Table and index names are atoms or strings as written.

t()

@type t() :: %Presubmit.Adapters.EctoMigration{
  disable_ddl_transaction?: boolean(),
  disable_migration_lock?: boolean(),
  functions: [:change | :up | :down],
  module: module(),
  ops: [{:change | :up | :down, op()}],
  path: String.t(),
  version: String.t() | nil
}

Functions

columns_added(ecto_migration, table)

@spec columns_added(t(), atom() | String.t()) :: [atom()]

Columns added to table by this migration, from create table and alter table ... add.

reversible?(ecto_migration)

@spec reversible?(t()) :: boolean()

Whether the migration can be rolled back: it defines up and down, or a change whose execute calls all carry a down statement.

version(path)

@spec version(String.t()) :: String.t() | nil

The timestamp prefix of a migration filename, or nil.