# `Bylaw.Credo.Check.Ecto.PreferDateTimeOverDate`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.1.0-alpha.1/lib/bylaw/credo/check/ecto/prefer_datetime_over_date.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

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

## Explanation

Prefer `:naive_datetime` or `:utc_datetime` over `:date` in Ecto schemas and
migrations when you need precise timestamps.

## Examples

Avoid:

      schema "events" do
        field :starts_on, :date
      end

      alter table(:events) do
        add :starts_on, :date
        modify :ends_on, :date
      end

Prefer:

      schema "events" do
        field :starts_at, :utc_datetime
      end

      alter table(:events) do
        add :starts_at, :utc_datetime
        timestamps(type: :utc_datetime)
      end

## Notes

Use `:naive_datetime`, `:utc_datetime`, or `timestamps/1` unless the field is
intentionally a calendar-only value. If a true date-only field is required,
disable the check locally with Credo.

This check uses static AST analysis, so it favors clear source-level patterns over runtime behavior.

## Options

This check has no check-specific options. Configure it with an empty option list.

## Usage

Add this check to Credo's `checks:` list in `.credo.exs`:

```elixir
%{
  configs: [
    %{
      name: "default",
      checks: [
        {Bylaw.Credo.Check.Ecto.PreferDateTimeOverDate, []}
      ]
    }
  ]
}
```

## Check-Specific Parameters

*There are no specific parameters for this check.*

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
