Liking cljdoc? Tell your friends :D

syncopate.schema

Declarative schema operations for Datalevin migrations.

A schema step carries exactly one operation, along two orthogonal axes:

existence axis (does the attribute exist at all): :schema/create - map of attr -> definition to add NEW attributes. Auto-invertible (its :down drops them again), which powers the auto-:down sugar in syncopate.core. :schema/remove - collection of attrs to drop. Datalevin won't drop an attr that still has datoms, so we retract them first. NOT auto-invertible (the data, and prior definitions, are gone) — supply an explicit :down or set :irreversible?.

definition axis (change an existing attribute's property keys): :schema/alter - map of attr -> definition, merged (patched) into the existing definition via update-schema. The attribute keeps existing. NOT auto-invertible (the prior definition is unknown) — supply an explicit :down (itself a :schema/alter describing the inverse change).

:schema/create and :schema/alter apply identically at run time (update-schema conn <map>); they differ only in declared reversibility. We never inspect the live schema to guess intent — the declared key IS the intent.

Declarative schema operations for Datalevin migrations.

A schema step carries exactly one operation, along two orthogonal axes:

  existence axis (does the attribute exist at all):
    :schema/create - map of attr -> definition to add NEW attributes.
                     Auto-invertible (its :down drops them again), which powers
                     the auto-`:down` sugar in `syncopate.core`.
    :schema/remove - collection of attrs to drop. Datalevin won't drop an attr
                     that still has datoms, so we retract them first. NOT
                     auto-invertible (the data, and prior definitions, are gone)
                     — supply an explicit :down or set :irreversible?.

  definition axis (change an existing attribute's property keys):
    :schema/alter  - map of attr -> definition, merged (patched) into the
                     existing definition via `update-schema`. The attribute
                     keeps existing. NOT auto-invertible (the prior definition
                     is unknown) — supply an explicit :down (itself a
                     :schema/alter describing the inverse change).

`:schema/create` and `:schema/alter` apply identically at run time
(`update-schema conn <map>`); they differ only in declared reversibility. We
never inspect the live schema to guess intent — the declared key IS the intent.
raw docstring

additive?clj

(additive? step)

True if step is a :schema/create — the only operation we can automatically invert (its :down removes the just-created attributes).

True if `step` is a `:schema/create` — the only operation we can automatically
invert (its :down removes the just-created attributes).
sourceraw docstring

alter?clj

(alter? step)

True if step is a well-formed :schema/alter step and names nothing else.

True if `step` is a well-formed `:schema/alter` step and names nothing else.
sourceraw docstring

apply-delta!clj

(apply-delta! conn step)

Apply a single schema operation to Datalog connection conn.

:schema/create and :schema/alter both merge their attr->definition map via update-schema (datalevin patches existing definitions). :schema/remove retracts every datom of each attr before dropping it.

Apply a single schema operation to Datalog connection `conn`.

`:schema/create` and `:schema/alter` both merge their attr->definition map via
`update-schema` (datalevin patches existing definitions). `:schema/remove`
retracts every datom of each attr before dropping it.
sourceraw docstring

create?clj

(create? step)

True if step is a well-formed :schema/create step and names nothing else.

True if `step` is a well-formed `:schema/create` step and names nothing else.
sourceraw docstring

invertclj

(invert {create :schema/create})

Invert a :schema/create: creating attrs becomes removing them. Only valid for :schema/create; :schema/alter and :schema/remove are not auto-invertible, so callers must guard with additive? first.

Invert a `:schema/create`: creating attrs becomes removing them. Only valid for
`:schema/create`; `:schema/alter` and `:schema/remove` are not auto-invertible,
so callers must guard with `additive?` first.
sourceraw docstring

legacy-schema-step?clj

(legacy-schema-step? step)

True if step uses the obsolete bare :schema key, which has been replaced by :schema/create (new attributes) and :schema/alter (modify existing ones). Detected so callers can give an actionable upgrade error rather than a cryptic "unrecognised step".

True if `step` uses the obsolete bare `:schema` key, which has been replaced by
`:schema/create` (new attributes) and `:schema/alter` (modify existing ones).
Detected so callers can give an actionable upgrade error rather than a cryptic
"unrecognised step".
sourceraw docstring

remove?clj

(remove? step)

True if step is a well-formed :schema/remove step and names nothing else.

True if `step` is a well-formed `:schema/remove` step and names nothing else.
sourceraw docstring

schema-delta?clj

(schema-delta? step)

True if step is a well-formed single schema operation — a create?, alter? or remove? step. A map naming more than one op is ambiguous?, not a delta (and is rejected with a clear error where migrations are built/run).

True if `step` is a well-formed single schema operation — a `create?`, `alter?`
or `remove?` step. A map naming more than one op is `ambiguous?`, not a delta
(and is rejected with a clear error where migrations are built/run).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close