mix scrypath.index.contract_drift (scrypath v0.3.5)

Copy Markdown View Source

Compares a schema's declared index contract (fields, filterables, sortables, faceting, and declared Meilisearch settings families) against the live index via a single read-only Meilisearch get_settings call.

Usage

mix scrypath.index.contract_drift MyApp.Blog.Post
mix scrypath.index.contract_drift MyApp.Blog.Post --json
mix scrypath.index.contract_drift MyApp.Blog.Post --repo MyApp.Repo --index-prefix tenant

Exit codes

  • 0 — comparison completed and every report dimension matches (match: true)
  • 2 — comparison completed with one or more dimensions match: false
  • 1 — could not complete (bad args, missing index, network, internal error)

Exit semantics match mix scrypath.settings.diff: drift uses exit 2; runtime failures use exit 1 via Mix.raise/2. The same rules apply with or without --json.

Shell pipelines

Use set +e before piping so a contract-drift exit of 2 does not abort the shell script; branch on $? afterward to distinguish parity (0) from drift (2).

API

The programmatic entry point is Scrypath.index_contract_drift/2, which returns {:ok, %Scrypath.Operator.IndexContractDrift.Report{}} or {:error, reason}.