The EDN sugar layer (ADR 0002): a Schema value — one data value
describing target state, mirroring the Snapshot's nesting — compiled
by ->sql to a vector of SQL statement strings the core consumes as
a normal Declaration. Pure; depends on nothing in the core.
The EDN sugar layer (ADR 0002): a Schema value — one data value describing target state, mirroring the Snapshot's nesting — compiled by `->sql` to a vector of SQL statement strings the core consumes as a normal Declaration. Pure; depends on nothing in the core.
(->sql schema)Compile schema — an EDN Schema value — to a vector of SQL statement
strings, a Declaration the core consumes like hand-written SQL.
The Schema value mirrors the Snapshot's nesting, with vectors where order matters:
{:tables [{:name id :columns [{:name id, :type kw-or-string, :primary-key? :autoincrement? :not-null? :unique? bools, :default value, :collate x, :check [:raw "..."]} ...] :primary-key [ids] | {:name id :columns [ids]} :uniques [[ids] | {:name id :columns [ids]} ...] :checks [[:raw s] | {:name id :check [:raw s]} ...] :foreign-keys [{:columns [ids] :ref-table id :ref-columns [ids] :name id :on-delete a :on-update a} ...] :indexes [{:name id :columns [id-or-raw ...] :unique? bool :where [:raw s]} ...] :triggers [sql-string-or-raw ...] :strict? :without-rowid? bools} ...] :views [sql-string-or-raw ...] :raw [sql-string-or-raw ...]}
Identifiers (keywords or strings) compile to quoted verbatim
spelling — no munging, no case folding. Column types are STRICT-legal
keywords (:int :integer :real :text :blob :any) compiled to canonical
uppercase, or any string passed through verbatim; unknown keywords
are rejected. Expression positions take [:raw "..."]; views and
triggers are raw-only at launch (whole CREATE statements). Tables
compile in declaration order, each followed by its nested indexes and
triggers; then views; then top-level :raw statements. Malformed
input throws :malformed-input.
Compile `schema` — an EDN Schema value — to a vector of SQL statement
strings, a Declaration the core consumes like hand-written SQL.
The Schema value mirrors the Snapshot's nesting, with vectors where
order matters:
{:tables [{:name id
:columns [{:name id, :type kw-or-string,
:primary-key? :autoincrement? :not-null?
:unique? bools, :default value, :collate x,
:check [:raw "..."]} ...]
:primary-key [ids] | {:name id :columns [ids]}
:uniques [[ids] | {:name id :columns [ids]} ...]
:checks [[:raw s] | {:name id :check [:raw s]} ...]
:foreign-keys [{:columns [ids] :ref-table id
:ref-columns [ids] :name id
:on-delete a :on-update a} ...]
:indexes [{:name id :columns [id-or-raw ...]
:unique? bool :where [:raw s]} ...]
:triggers [sql-string-or-raw ...]
:strict? :without-rowid? bools} ...]
:views [sql-string-or-raw ...]
:raw [sql-string-or-raw ...]}
Identifiers (keywords or strings) compile to quoted verbatim
spelling — no munging, no case folding. Column types are STRICT-legal
keywords (:int :integer :real :text :blob :any) compiled to canonical
uppercase, or any string passed through verbatim; unknown keywords
are rejected. Expression positions take `[:raw "..."]`; views and
triggers are raw-only at launch (whole CREATE statements). Tables
compile in declaration order, each followed by its nested indexes and
triggers; then views; then top-level `:raw` statements. Malformed
input throws `:malformed-input`.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |