AshCredo.Check.Design.MissingTimestamps (ash_credo v0.12.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 normal and works with any version of Elixir.

Explanation

Ash resources backed by a data layer should include timestamps. Timestamps are essential for auditing, debugging, and cache invalidation.

Add timestamps() inside your attributes block, or use create_timestamp :inserted_at and update_timestamp :updated_at.

This check uses Ash's runtime introspection (Ash.Resource.Info.attributes/1) to detect timestamp attributes - including ones contributed by Spark transformers or extensions - rather than scanning the source AST. This means custom timestamp entity names are caught as long as they produce attributes with an auto-generated default (for create timestamps) or update_default (for update timestamps).

Requirements

Your project must be compiled before running mix credo. If Ash is not available in the VM running Credo, the check is a no-op and emits a single diagnostic.

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.