View Source ExcellentMigrations.Runner (excellent_migrations v0.1.8)

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

@type danger() :: %{type: danger_type(), path: String.t(), line: integer()}
@type danger_type() ::
  :check_constraint_added
  | :column_added_with_default
  | :column_reference_added
  | :column_removed
  | :column_renamed
  | :column_type_changed
  | :column_volatile_default
  | :index_concurrently_without_disable_ddl_transaction
  | :index_concurrently_without_disable_migration_lock
  | :index_not_concurrently
  | :json_column_added
  | :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
@spec check_migrations([{:migrations_paths, [String.t()]}]) ::
  :safe | {:dangerous, [danger()]}

Detects potentially dangerous database operations in database migration files.

options

Options

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

scope-of-analysis

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.