Rbtz.CredoChecks.Warning.DisableMigrationLock (rbtz_credo_checks v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Forbids @disable_migration_lock true in Ecto migration files.

The migration lock prevents two deployment processes from running the same migration concurrently — disabling it can leave the schema in an inconsistent state under any rolling-deploy scenario. This project additionally configures migration_lock: :pg_advisory_lock globally, so the per-migration override should never be needed.

If a long-running migration genuinely cannot hold the lock (e.g. CREATE INDEX CONCURRENTLY), break it into a separate migration that uses @disable_ddl_transaction true and discuss the deploy plan with the team rather than silently disabling locking.

Bad

defmodule Repo.Migrations.AddIndex do
  use Ecto.Migration
  @disable_migration_lock true

  def change, do: ...
end

Good (no override needed; rely on global config)

defmodule Repo.Migrations.AddIndex do
  use Ecto.Migration

  def change, do: ...
end

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.