AshCredo.Check.Warning.MissingPrimaryKey (ash_credo v0.5.2)

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

Ash resources backed by a data layer need a primary key. Missing one causes runtime errors on reads and relationships.

Add one of these inside your attributes block:

uuid_primary_key :id
uuid_v7_primary_key :id
integer_primary_key :id
attribute :id, :uuid, primary_key?: true, allow_nil?: false

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.