ExcellentMigrations.Runner (excellent_migrations v0.1.3) View Source

This module finds migration files in a project and detects potentially dangerous database operations in them.

Link to this section Summary

Functions

Detects potentially dangerous database operations in database migration files.

Link to this section Types

Specs

danger() :: %{type: danger_type(), path: String.t(), line: integer()}

Specs

danger_type() ::
  :column_added_with_default
  | :column_removed
  | :column_renamed
  | :column_type_changed
  | :index_not_concurrently
  | :many_columns_index
  | :not_null_added
  | :operation_delete
  | :operation_insert
  | :operation_update
  | :raw_sql_executed
  | :table_dropped
  | :table_renamed

Link to this section Functions

Link to this function

check_migrations(opts \\ [])

View Source

Specs

check_migrations([{:migrations_paths, [String.t()]}]) ::
  :safe | {:dangerous, [danger()]}

Detects potentially dangerous database operations in database migration files.

Options

  • :migrations_paths - optional list of file paths to be checked.

    Scope of analysis

  • If migrations_paths are specified, the analysis will be narrowed down to these files only.
  • If not and application env :excellent_migrations, :start_after is set, only migrations with timestamp older than the provided one will be chosen.
  • If none of the above, all migration files in a project will be analyzed.