Finds where your Ecto schemas and changesets disagree with your database.
Most people run it with mix ecto.doctor.
Call diagnose/2 to use the findings in your own code.
{:ok, findings} = EctoDoctor.diagnose(MyApp.Repo)It reads your schemas through reflection and your changesets from source. Then it reads the live database and compares the three. Nothing is written.
Options
:apps(list ofatom/0) - Picks the apps whose schemas are checked. Defaults to the repo's app.:only- Runs only these checks.:except- Skips these checks. The default value is[].:all(boolean/0) - Reports info level findings too. The default value isfalse.:checks- Sets options for single checks.falseturns a check off andignoretakes table or column patterns. The default value is[].:ignore_tables(list ofString.t/0) - Leaves these tables out of every check. One*matches anything. The default value is["schema_migrations", "oban_*"].:baseline- Leaves out the findings listed in this file. Set it to nil to report everything. The default value is".ecto_doctor_baseline.exs".
Config file
mix ecto.doctor also reads .ecto_doctor.exs from the project root.
It holds the same options as a keyword list.
[
checks: [orphan_table: [ignore: ["legacy_*"]], string_length_overflow: false],
ignore_tables: ["schema_migrations", "oban_*", "pg_search_documents"]
]A schema can also turn checks off for itself with a comment like # ecto_doctor:ignore missing_not_null inside its module.
Summary
Functions
Runs every check against the repo and returns the findings with the most severe first.
Functions
@spec diagnose(Ecto.Repo.t(), keyword()) :: {:ok, [EctoDoctor.Finding.t()]} | {:error, EctoDoctor.Error.t()}
Runs every check against the repo and returns the findings with the most severe first.
Findings listed in the baseline file are left out.