OptimumCredo.Check.Warning.ReferenceWithoutOnDelete (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

Declare what happens to child rows when the referenced row is deleted.

Bad

add :user_id, references(:users)

Good

add :user_id, references(:users, on_delete: :delete_all)

Check-Specific Parameters

Use the following parameters to configure this check:

:require_on_delete

Report references that do not declare on_delete.

This parameter defaults to true.

: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.