Dextrin.Schema.Compat (Dextrin v0.3.2)

Copy Markdown View Source

The version discipline check (DXNS.md §8): compares the schemas of a previous release with the current ones.

  • A schema whose content changed must have a new version. A version present in both whose fields differ -- a field added, removed, moved, or one whose type, requiredness or default changed -- is a problem: two documents claiming to be User v3 must mean the same thing.
  • A version never goes down. A schema whose latest version is lower than before is a problem.
  • Informational: what the materializer has to upgrade. For each schema, every older version still loaded beside the latest, with the fields the latest added, removed and changed since -- a checklist for the materializer's branches.

There are no compatibility modes and no append-only rule: changing positions is allowed, and documented as what older readers misread (DXNS.md §8). A field's description is documentation, not content. CI runs this against the previous release's schema files (mix dextrin.compat OLD NEW).

Summary

Functions

old's schemas against new's: the problems, and the upgrade checklist for new, each sorted by schema name and version.

Types

problem()

@type problem() ::
  %{
    schema: String.t(),
    version: pos_integer(),
    problem: :changed_without_new_version
  }
  | %{
      schema: String.t(),
      problem: :version_went_down,
      from: pos_integer(),
      to: pos_integer()
    }

upgrade()

@type upgrade() :: %{
  schema: String.t(),
  from: pos_integer(),
  to: pos_integer(),
  added: [String.t()],
  removed: [String.t()],
  changed: [String.t()]
}

Functions

check(registry1, registry2)

@spec check(Dextrin.Registry.t(), Dextrin.Registry.t()) :: %{
  problems: [problem()],
  upgrades: [upgrade()]
}

old's schemas against new's: the problems, and the upgrade checklist for new, each sorted by schema name and version.