OptimumCredo.Check.Warning.NotNullWithoutDefault (OptimumCredo v0.5.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

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

Explanation

Adding a NOT NULL column to an existing table needs a default or a backfill.

Bad

alter table(:users) do
  add :status, :string, null: false
end

Good

alter table(:users) do
  add :status, :string, null: false, default: "active"
end

Heuristic: table contents and migration history are unknown to the check.

Check-Specific Parameters

Use the following parameters to configure this check:

:ignore_files

Path suffixes or regexes for migrations to skip.

This parameter defaults to [].

General Parameters

Like with all checks, general params can be applied.

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