Changelog
View SourceAll notable changes to this project will be documented in this file.
git-cliff writes this file from the commit subjects. What a release changes for an application that runs on kura, and each setting with its default, is in Upgrading.
[2.31.2] - 2026-11-16
Bug Fixes
- (migrator) Keep the operations of a migration in the order written
[2.31.1] - 2026-11-16
Bug Fixes
- (schema) Read a renamed column into its field when the driver names it in text
[2.31.0] - 2026-11-16
Bug Fixes
- (query) Compile an empty in or not_in list to a constant predicate
- (repo) Bind every value in get, get_by and reload
- (dialect) Leave a ? inside fragment text alone and check the count
- (paginator) Validate page, page_size and limit, add max_page_size
- (repo) Insert_all with no entries, uneven entries or too many values
- (schema) Honour #kura_field.column in statements and loaded rows
- (schema) Read the timestamps/0 callback
- (dialect) A join returns the from row and names a joined schema's columns
- (migrator) Write the version statements with the dialect's placeholder
- (dialect) Put a combined query's ORDER BY, LIMIT and OFFSET after its branches
- (tenant) A scope ends with its work and reaches kura's preload processes
- (repo) Report an undeclared constraint on its column's field or on base
- (telemetry) Drop the error's message and detail, cover every schema a query reads
- (schema) Make no atom from a column name or a confirmation name
- (types) Keep a decimal given as text exact instead of making it a float
- (dialect) Read a backend's stored forms in its dialect, not in kura_types:load
- (capabilities) Check a backend only once it declares a capability model
- (query) Read PostgreSQL's whole locking clause and pass other text through
- (tenant) Require a tenant for what a query joins, not only what it is from
- (schema) Stamp by field name when timestamps/0 cannot be used
- (schema) Do not remember that a module had no load plan
- (tenant) A CTE's body reads a table where it names itself or a later CTE
- (redact) Judge a condition by the redacted fields of every source in the query
- (tenant) Refuse an attribute tenant whose value is undefined, null or nil
- (redact) Keep a redacted value out of a changeset's errors
- (schema) A module loaded after its name was first asked about is a schema
- (query) Warn about lock text only while strict_locks is unset
- (schema) Keep stamping inserted_at and updated_at beside timestamps/0
- (schema) A module loaded later is read whatever is asked of it first
- (paginator) One error for a max_page_size kura cannot use
- (telemetry) Name the table after TABLE IF EXISTS as a raw statement's source
- (telemetry) Report the rows a write affected as num_rows
- (redact) The logging helpers return whatever they are given
- (tenant) An attribute tenant's field is a field, not a condition
- (telemetry) The raw SQL source is read from statement text only
- (cache) A cached plan kura cannot read is compiled again
- (redact) Read a changeset's fields as what they hold
- (tenant) Leave a tenant field a schema does not declare to the database
- (changeset) Report a confirmation mismatch on the confirmation where its atom exists
- (query) Compile a fragment condition as one group
- (tenant) Leave a schema every tenant shares out of the tenant condition and its writes, match one that declares the tenant's field, refuse one that does neither where a tenant is required
- (audit) Write the audit row of a write under an attribute tenant without the tenant
- (redact) Hide a record or changeset of a module that is no schema
- (redact) Redact an embed whose schema lists redacted fields
- (redact) Hide a changeset's params under keys that name no field, embed or association, and the error messages that quote them
- (preload) Give preload/4 a spec that takes a conditional preload
- (query) Give preload/2 and the query record a type that takes a conditional preload
Documentation
- (query) Escape_like/1 patterns match the same text on SQLite
- Add a security policy
- (changelog) Section the releases since 2.0.0 and list the unreleased changes
- (api) Hide the functions kura's modules call between themselves
- (tenant) Say that adopt/1 lasts for the process's life and where not to use it
- (ci) Say which CI jobs hold a write token and why
- (pool) Say why kura_pool_ets declares no capability model
- (tenant) An explicit prefix is not a tenant check
- (capabilities) List the capabilities with colons, not dashes
- (capabilities) Say which repo's queries are not checked
- (tenant) The 3.0 default is a plan, raw SQL goes through query/3
- (query) An atom that is a schema module names its table in a lock
- (readme) The settings that change in 3.0 are unset, not false
- (telemetry) Link opentelemetry_kura where it lives
- (upgrading) What changes after 2.30.0, each setting with its default, the new API
- (upgrading) What the redaction, tenant, source and cache fixes change
- (migrator) Keep record_sql/2 out of the generated documentation
- (query) Say that sources/1 may list more roles in a later release
- (upgrading) The lock term a dialect receives and text matches on SQLite
- (upgrading) What waits for the next kura_sqlite and rebar3_kura
- (changelog) Describe 2.31.0 as it ships
- (upgrading) Which fragment conditions change their result, and what to check
- (multitenancy) Show the line a fragment's closing parenthesis is written on
- (tenant) A schema every tenant shares is read from the tenant's schema under a prefix tenant
- (redact) An embed is redacted for a redacted field at any depth, and the logging helpers have an entry of their own
- (multitenancy) The scoping list is for a schema that declares the tenant field
- (multitenancy) Without a tenant, tenant_scoped/0 alone exempts a schema from require_tenant
- (tenant) In a process without a tenant a schema that returns false is not asked for one, whatever fields it declares
Features
- (query) Literal text matches and escape_like/1
- (capabilities) Refuse a query the backend does not declare support for
- (changeset) Allow-list for nested casts and strict_assoc_cast
- (tenant) Require_tenant makes a missing tenant an error
- (encryption) Warn once when the v1 write format is only the default
- (redact) Keep sensitive field values out of telemetry and logs
- (capabilities) Check row_locks, distinct_on and cursors
- (migration) Name a column by a binary as well as by an atom
- (tenant) Make require_tenant a repo setting
Miscellaneous
- (lint) Clear the ELP diagnostics
Refactor
- Satisfy eqwalizer and elp lint on the new code
- (query) Walk a query's sources and nested queries in one place
- (settings) Read kura's settings in one place and check them at boot
- (query) Read a lock map's wait in a typed step
- (query) Drop a clause of cte_names that cannot match
- (redact) Drop a clause of names_field that cannot match
- (tenant) Define the condition words a tenant field cannot be where they are used
Testing
- (repo) Execute the NOT NULL violation mapping against PostgreSQL
- (dialect) The SQLite stand-in rewrites only placeholders
- (postgres) Run against the released kura_postgres modules and fail when they drift
- (postgres) Transactions, sandbox and pool start through the real driver
- (migrator) Deny CREATE on public before the bootstrap-failure case
- (bench) Time all/2 on a cached shape and a job queue's loop
- (bench) Time the cached shapes on a repo whose settings are stored
- (settings) A decided setting logs no warning
- (tenant) Reach the cache hit before asserting a hit is refused
- Share ill_typed/1 between the test modules that were given a copy
- (prop) Properties for the code that reads caller-written SQL text
- (query) Check escape_like against PostgreSQL's LIKE and ILIKE
- (boot_warning) Cover once/2 and forget/1
- A killed run leaves no log handler or lock setting behind
- (capabilities) Expressions after the first, lock maps and lists, a pool module not yet loaded
- (tenant) The unset warning from a direct compile and from a cache hit, a write that names no table
- (compiler) An uncacheable shape hands back its facts
- (query) The like-escape suite's repo module
- (schema) Ask about a module with nothing remembered of it
- (prop) Dollar-quote tags of any identifier byte, and what is not a tag
- (query) Sources/1 reads what follows an entry it cannot read
- (repo) A delete shows its key in telemetry
- (settings) A page size of 1, a repo's require_tenant, and what a refused value is told to be
- (redact) Parameters by position and by touch, binary param keys, a later distance, a stream's cursor
- (app) Start with valid settings, and with one that is not
- (dialect) Placeholder/2, of_repo/1 and loads_stored/1, for a dialect that is loaded, unloaded or missing
- (repo) A started repo takes a false require_tenant from the application environment
- (telemetry) The source of raw SQL with keywords in any case, and keywords inside longer words
- (redact) Nested values, a schema with nothing hidden and update_all parameters
- Kept cache entries, a union's later branch, a statement's result and bytes at the edge of a name
- Read compiled SQL and a logged report as binaries
- (schema) A record of a module not loaded yet is hidden, not passed through
Build
- (mutate) Run the suites that cover each module's new code
- (mutate) Run the capability and tenant suites against the query compiler
- (mutate) Run the statement suites against the repo worker
- (mutate) Run the suites that cover them against db, dialect, stream, preloader, assoc casts and repo settings
- (mutate) Run the redaction properties against kura_redact
Perf
- (db) Look a schema up once per result set and find the source without a regex
- (query) Work out a query shape's tenant, redaction and source once
- (db) Load a row as before when the dialect reads no stored forms
- (compiler) Walk a query's sources once for its facts
- (schema) A kept schema answer is one read
Style
- Sigil for two binaries, drop comments that restate the code
[2.30.0] - 2026-11-05
Features
- Scope count and stream, run insert/3 hooks, qualify join columns, dump where values (#217)
[2.29.0] - 2026-11-03
Features
- (encryption) Deterministic mode with equality lookups (#219)
[2.28.0] - 2026-11-03
Features
- (encryption) V2 column-bound ciphertext frame with HKDF subkeys (#213)
[2.27.0] - 2026-11-03
Features
- (migrator) Create_index using, opclass and with; honour name (#212)
[2.26.0] - 2026-11-03
Features
- (query) Pgvector distance threshold in where and having (#211)
[2.25.1] - 2026-11-03
Bug Fixes
- (sandbox) Detect a statement that ends the sandbox's transaction (#210)
[2.25.0] - 2026-11-03
Features
- (migrator) Run a migration outside a transaction for CREATE INDEX CONCURRENTLY (#203)
[2.24.0] - 2026-11-03
Features
- Release 2.24.0 (#202)
[2.23.1] - 2026-10-25
Bug Fixes
- (verify) Match declared indexes by structure, not by name (#185)
[2.23.0] - 2026-10-25
Features
- (query) Cache compiled queries by shape, not bound values (#184)
[2.22.1] - 2026-10-25
Bug Fixes
- (tenant) Confine attribute tenancy to every query, write and preload (#187)
[2.22.0] - 2026-10-24
Features
- (schema) Forget/1 drops a module's cached lookups (#183)
[2.21.0] - 2026-10-24
Features
- (migrator) Baseline up to a version with fake/2 and fake/3 (#182)
[2.20.12] - 2026-08-28
Bug Fixes
- Close the quoting gaps and honour on_conflict in bulk inserts (#181)
[2.20.11] - 2026-08-28
Bug Fixes
- Quote every identifier and fail closed on dump errors (#180)
[2.20.10] - 2026-08-26
Miscellaneous
- Attribute licence to Daniel Widgren (#179)
[2.20.9] - 2026-08-11
Testing
- Wire up the CT suites ELP reported as unreachable, and bump erlang-ci (#176)
[2.20.8] - 2026-08-10
Miscellaneous
- (deps) Test against minato 1.0 (#175)
[2.20.7] - 2026-08-06
Testing
- Stop the docker resilience tests poisoning the shared pools (#174)
[2.20.6] - 2026-08-06
Miscellaneous
- Take every plugin from hex and drop the sbom fork (#173)
[2.20.5] - 2026-08-06
Miscellaneous
- Require minato ~> 0.18 in the test profile (#172)
[2.20.4] - 2026-08-05
Documentation
- The behaviour examples name the backend kura selects (#171)
[2.20.3] - 2026-08-05
Bug Fixes
- (query-cache) Key compiled-query cache on the query, not a phash2 (#164)
[2.20.2] - 2026-08-05
Testing
- Cover the minato driver (#170)
[2.20.1] - 2026-08-04
Refactor
- (types) Point the on_delete unions at kura_schema:on_delete/0 (#168)
[2.20.0] - 2026-08-04
Features
- (migrator) Multi-application migration discovery (#167)
[2.19.0] - 2026-08-04
Features
- (schema) On_delete on #kura_assoc (#166)
[2.18.1] - 2026-07-06
Documentation
- (migrations) Document fake/1 baselining for existing databases (#158)
[2.18.0] - 2026-07-06
Features
- (migrator) Fake/1 - baseline pending migrations without running DDL (#157)
[2.17.1] - 2026-07-06
Documentation
- (assoc) Document composite many_to_many join_keys (#155)
[2.17.0] - 2026-07-06
Features
- (assoc) Composite many_to_many join keys (#154)
[2.16.0] - 2026-07-06
Features
- (repo) Composite FK write for owned associations (persist side) (#152)
[2.15.1] - 2026-07-06
Documentation
- Document composite primary + foreign keys (#149)
[2.15.0] - 2026-07-06
Features
- (changeset) Composite-safe association casting (#148)
[2.14.0] - 2026-07-06
Features
- (preload) Composite foreign keys for has_many and has_one (#147)
[2.13.0] - 2026-07-06
Features
- (preload) Composite foreign keys for belongs_to (#146)
[2.12.0] - 2026-07-06
Features
- (schema) #kura_ref record + assoc_fields/1 (composite-FK foundation) (#145)
[2.11.0] - 2026-07-06
Features
- (repo) Write-side addressing by composite key (#144)
[2.10.0] - 2026-07-06
Features
- (migrator) Composite PRIMARY KEY DDL + composite-safe auto-gen (#143)
[2.9.0] - 2026-07-06
Features
- Uniform key accessor + read-side composite-key addressing (#142)
[2.8.1] - 2026-07-05
Documentation
- Correct SQLite window over-claim + document json capability variant (#140)
[2.8.0] - 2026-07-05
Features
- (types) Pgvector support via {vector, N} (#138)
[2.7.0] - 2026-07-05
Features
- (encryption) At-rest field encryption via {encrypted, Type} (#136)
[2.6.0] - 2026-07-05
Features
- (query) Full-text search via the matches operator (#133)
[2.5.0] - 2026-07-05
Features
- (types) From_pg_type/2 - invert to_pg_type for introspection (#134)
[2.4.0] - 2026-07-05
Features
- (repo) Read_only repos and explicit replica routing (#132)
[2.3.0] - 2026-07-05
Features
- (changeset) Exclusion_constraint for PG EXCLUDE constraints (#131)
[2.2.0] - 2026-07-05
Features
- (query) Window functions via over/2 (#130)
[2.1.0] - 2026-07-05
Features
- (uuid) Configurable v4/v7 primary keys (default v4) (#128)
[2.0.9] - 2026-07-04
Bug Fixes
- Quote atom/enum defaults in generated DDL (#124) (#127)
[2.0.8] - 2026-06-09
Documentation
- (ex_doc) Fix all warnings (#121)
[2.0.7] - 2026-06-09
Bug Fixes
- (types) Dump jsonb string scalars (#123)
[2.0.6] - 2026-05-25
Documentation
- (pool) Drop reference to kura_pool_hnc (#120)
[2.0.5] - 2026-05-25
Bug Fixes
- (otp29) Replace deprecated catch with try/catch + add OTP 29 to CI matrix (#119)
[2.0.4] - 2026-05-14
Bug Fixes
- (types) Accept scalar values in jsonb cast/dump/load (#118)
[2.0.3] - 2026-05-10
Bug Fixes
- (migrator) Code:ensure_loaded dialect before function_exported check (#117)
[2.0.2] - 2026-05-10
Bug Fixes
- (migrator) Portable schema_migrations DDL for non-Postgres backends (#116)
[2.0.1] - 2026-05-10
Documentation
- Multi-repo config in getting-started + MIGRATION-2.0 (#114)
- Lead with {repos, #{...}} map form everywhere (#115)
Notes on 2.0.1 to 2.30.0
Written while these releases sat under one Unreleased heading. The sections above say which release a change shipped in; these say what it does.
Added
kura_dialect:qualified_columns/1, public: which bare fields of a joined query a dialect qualifies with thefromtable (see Changed).- The exported type
kura_repo_worker:hook_error/0, a hook's{error, Reason}in the specs ofinsert/2,3andupdate/2. kura_query:from/1andjoin/4,5specs accept a binary table or CTE name.- Optional
kura_dialectcallbackconvert_values/1: a dialect converts a query's bound values before it is compiled.kura_dialect_pgimplements it (see Changed). kura_changeset:delete_change/2removes a field from a changeset's changes, leaving data and params as they are (as Ecto does), for example to drop a virtual password once it is hashed.- Deterministic field encryption and equality lookups (kura#137).
{encrypted, Inner, Opts}takes a closed set of options, checked when a schema is first read:mode(randomized|deterministic, defaultrandomized),normalize(none|casefold|nfc|nfc_casefold, deterministicstring/textonly;nfc_casefolddecomposes before folding, so canonically equivalent forms store and look up equally),context({Table, Column}, pins the binding so a rename keeps values readable, or lets two columns share ciphertexts) andlegacy(accept|reject, defaultreject). A bad options map raises{kura, {invalid_encryption_options, Mod, Field}},{kura, {unknown_encryption_option, Mod, Field, Key}},{kura, {invalid_encryption_option, Mod, Field, Key}}or{kura, {unsupported_deterministic_type, Mod, Field}}. The options form always writes v2 frames. A deterministic value is encrypted with HMAC-SIV-GCM (frame mode1): the IV is the first 12 bytes of HMAC-SHA-256 under a per-column MAC key, over the AAD and the value, and AES-256-GCM runs under a separate per-column key; decryption recomputes the IV and raises{kura_crypto, {noncanonical, KeyId}}on a mismatch. Inner types:string,text,binary,uuid(compared lowercase),integer,bigint,smallint;boolean,jsonband arrays are refused.legacy => rejectrefuses a v1 frame ({kura_crypto, {refused_version, 1}}) and a v2 frame of the other mode ({kura_crypto, {refused_mode, ModeByte}}, the frame's mode byte) per column, which covers per column what kura#214 proposes as a node-wide switch. Deterministic mode reveals which rows share a value, and a lookup's ciphertext is a stable pseudonym in telemetry and logged parameters; both modes reveal length andNULL-ness, and the value stays personal data under the GDPR. A unique index holds within one deterministic key generation. Keep a column under 2^32 distinct values per key. On SQLite the options form needs kura_sqlite 1.2.0 or later. kura_query:where/2andhaving/2turn=, bare equality,in,!=andnot_inon a deterministic field into{Field, encrypted_in | encrypted_not_in, Ciphertexts}before the condition is stored, so the plaintext never reaches the query, the query cache, telemetry or logs. The PG dialect compiles them toINandNOT IN. A value that does not cast raises{kura, {invalid_lookup_value, Field}}; passing either operator towhere/2raises{kura, {reserved_operator, Op}}; and the compile-time check refuses one on a field the query cannot look up, or with values not laid out as deterministic frames, with{kura, {invalid_encrypted_lookup, Field}}. A field encrypted in two sources of a query, or read through a CTE, is not looked up. The query cache keys a lookup by shape only when every value has the frame layout. For a deterministic fieldwhere/2andhaving/2read the keyring, so they can raise a keyring error such as{kura_crypto, no_deterministic_key}. The rewrite costs about 30-60 ns perwhere/2on a schema without deterministic fields.kura_encryption:lookup_params/3returns the ciphertexts a lookup binds, for a{fragment, SQL, Params}.kura_keyringgains the optional callbacksdeterministic_active/0anddeterministic_key_ids/0, andkura_keyring_envimplements both (deterministic_activeanddeterministic_keysin theencryptionconfig; an id indeterministic_keysthat is not inkeysraises{kura_crypto, {unknown_key_id, Id}}, anything but a list of key ids{kura_crypto, invalid_deterministic_keys}). Deterministic writes usedeterministic_active, neveractive, and raise{kura_crypto, no_deterministic_key}without one. A lookup is encrypted underdeterministic_activeand every otherdeterministic_key_ids/0id, at most 8 ({kura_crypto, {too_many_lookup_keys, N}}beyond); randomized rotation keys never enter a lookup. Rotate a deterministic key by making the new keydeterministic_activeand keeping the old id indeterministic_keysuntil no stored value uses it;!=andnot_inare correct only while every stored generation is a lookup key.kura_crypto:encrypt/3anddecrypt/3;kura_types:validate_encryption/1anddeterministic_inner/1; the typeskura_crypto:mode/0,legacy/0andpolicy/0,kura_types:encryption_opts/0andnormalize/0, andkura_schema:field_encryption/0.- A pgvector distance threshold in
where/2andhaving/2:{kura_query:distance(Field, Metric, Vector), Op, Number}withOpone of'<','<=','>','>=', also under'and','or'and'not'. The PG dialect emits"col" <=> $N < $M, numbered in the where's or having's place. The distance is checked against the schema as inorder_by/2, a threshold that is not a number raises{kura, {invalid_distance_threshold, Field}}, and the encrypted-field guard checks the distance's column. The query cache replaces both the vector and the threshold with markers. The compiler's distance check now covers the thresholds of a hand-built where or having, and the subqueries ofin,existsandnot_existsconditions; it walks structure only, never into bound values, and refuses a distance that is itself a condition's value with{kura, {distance_not_supported_here, Clause}}. A distance in any other condition still raises that fromwhere/2andhaving/2. - Map-form
create_indextakesusing(access method, such ashnsw,ivfflat,gin),opclass(operator class, one column only) andwith(storage parameters, atom keys to integers), for pgvector HNSW and IVFFlat indexes among others.using,opclassand thewithkeys must match^[a-z][a-z0-9_]*$and are emitted quoted. A bad identifier, a non-integerwithvalue, an emptywithmap,opclasson several columns or anamethat is not a binary of 1 to 63 bytes raises{invalid_index_option, Option, Value}. A migration run checks every map-formcreate_indexbefore it applies anything, and fails with{invalid_index_option, Version, Option, Value}. On a repo whose dialect is not PostgreSQL,using,opclassandwithraise{invalid_index_option, Option, {unsupported_dialect, Dialect}}. kura_migration:index_name/3resolves the name of an index from its options: the declaredname, orindex_name/2.kura_schema_verifycompares the access method (pg_am.amname) of a declared index that names one withusing, so a btree no longer satisfies a declaredhnswindex. Withoutusingany method counts.
Changed
count/2,aggregate/3,4andkura_stream:stream/3,4leave out soft-deleted rows, asall/2,update_all/3anddelete_all/2already did; mark the query withkura_query:with_deleted/1to keep them.all/2on a queryfroma CTE name or a bare table atom no longer crashes.insert/3(an insert with options such ason_conflict) runsprepare_changes/2,before_insert/1,after_insert/1and the changeset's associations, likeinsert/2.after_insert/1runs whenever the statement returns a row, including when an upsert updated one. A changeset with associations refuses anyon_conflictaction butnothing(with or without a guard), raising{kura, on_conflict_with_assocs}.On PostgreSQL, a where value compared to a field of the
fromschema is converted when the query is compiled, only where it then binds what the database would parse from it: an enum atom binds its binary, and a binary in cast form binds the scalar it spells onid,integer,bigint,smallint,float,boolean,dateandtimefields, and on datetimes without an offset other thanZor a fraction. An integer binary over 20 bytes or a float binary over 64 is not parsed. Every other value,decimalincluded, is bound as given. The conversion is the new optionalkura_dialectcallbackconvert_values/1, implemented bykura_dialect_pg;kura_query:where/2stores the condition as given, and a dialect without the callback (kura_sqlite) binds every value as given, so a boolean filter on SQLite is not turned into the text'true'. The conversion reaches the subqueries, CTEs and combined queries of a query, each against its ownfromschema.kura_repo_worker:update_all/3anddelete_all/2raise{kura, {unsupported_in_bulk_write, Clause}}for a query with a join,order_by,group_by, having, limit, offset, distinct, CTE or combination. The bulk statements compile only thefromtable, the where conditions and the prefix, so these clauses used to be dropped silently:delete_allon a joined query deleted every row its where matched in thefromtable, or every row when the where was on the joined table. Filter with a{id, in, {subquery, Q}}condition instead.kura_types:cast/2(and sokura_changeset:cast/4) refuses an out-of-range date or time: an hour over 23 (but24:00:00), a minute over 59, a second over 60, a year outside 1..9999 or not four digits, and a day the month does not have. These used to be accepted as given.After a join, the PostgreSQL dialect qualifies a bare field of the
fromschema with thefromtable in select, where, having, order_by, group_by, distinct and window specs, so a column both tables have is no longer ambiguous. The attribute-tenancy field andorder_bynames that areselect_expr/2aliases stay bare. Which fields are qualified is decided by the newkura_dialect:qualified_columns/1. kura_sqlite delegates to this dialect and inherits the qualification; a where on a byte field of thefromschema under a join needs the kura_sqlite release that useskura_dialect:qualified_columns/1. A deterministic lookup on a field of thefromschema is offered only by thefromschema, so a plainfromfield with a deterministic namesake in a joined schema raises{kura, {encrypted_field_in_where, Field}}instead of comparing the joined schema's ciphertexts with the plain column.kura_changeset:validate_length/3measures a binary in characters (Unicode code points, the unit ofVARCHAR(N)) rather than bytes, so a multibyte string counts fewer units than before. A value that is not valid UTF-8 gets the erroris not valid UTF-8. On a field typedbinaryor{encrypted, binary}it still counts bytes, and the messages say byte(s).cast/4looks uptable/0only when the schema declares constraints or indexes, so an embedded schema module needs onlyfields/0.kura_types:encryption/1returns the full spec, withmode,legacyandnormalize, andkura_schema:encryption_specs/1returns it withcontextresolved, in place of#{context => Ctx}alone.kura_crypto:decrypt/2(the{encrypted, Inner}read path) reads a deterministic v2 frame of its column, aslegacy => acceptdoes; a frame with its mode byte changed from0to1now raisesbad_tagrather than{unsupported_mode, 1}.An attribute tenant on a deterministic field raises
{kura, {encrypted_field_in_where, Field}}when a query is scoped, as on a randomized field: writes refuse an encrypted tenant field in either mode.Map-form
create_indexhonoursname. It used to be ignored, the index always takingkura_migration:index_name/2. A migration that passednamenow creates the index under that name, and a unique index declared inindexes/0with anamemaps its constraint violations under both that name and the generated one, so an index created earlier under the generated name keeps mapping without a rename. Renaming it to the declared name is optional. Withoutname, naming is unchanged.Breaking: a
namethat is not a binary of 1 to 63 bytes (an atom,~"",undefined, a longer binary) used to be ignored. It now raises{invalid_index_option, name, Name}. On a unique index inindexes/0it raises fromkura_changeset:cast/4on every write to that schema. In a migration'screate_indexit aborts the run, including an applied migration replayed on a fresh database. Writename => ~"users_email_index", not an atom.{Field, is_nil}and{Field, is_not_nil}on an encrypted field are accepted bywhere/2. They bind nothing, andNULLis stored unencrypted.order_by/2on an encrypted field raises{kura, {encrypted_field_in_order_by, Field}};sum,avg,minormaxof one, inselect/2, the aggregate helpers or a window function, raises{kura, {encrypted_field_in_aggregate, Field}}; and a windowpartition_byororder_byon one raises{kura, {encrypted_field_in_window, Field}}. The result would be ordered or computed over ciphertexts.countis allowed. The compiler re-check covers these too.group_by/2,distinct/2(DISTINCT ON) and ajoinoncolumn on an encrypted field raise{kura, {encrypted_field_in_group_by, Field}},{kura, {encrypted_field_in_distinct, Field}}and{kura, {encrypted_field_in_join, Field}}: equal values encrypt to different ciphertexts, so they never group or join. ORDER BY, GROUP BY and DISTINCT ON on aselect_expr/2alias of an encrypted field raise too. Aselect_expr/2distance over a column that may hold ciphertext raises{kura, {encrypted_field_in_select, Field}}. A term in a column position that is not a column is reported asnot_a_column, so its values stay out of the reason.kura_schemarefuses an encrypted primary key, association key (foreign key, referenced key or join-table key) or a field of an embedded schema, raising{kura, {encrypted_primary_key, Mod, Field}},{kura, {encrypted_association_key, Mod, Assoc, Field}}or{kura, {encrypted_embed_field, Mod, Embed, Field}}the first time it reads the schema. None of these could work: keys are matched by equality and an embed is stored as one JSON document.A type tagged
encryptedin any form other than{encrypted, Inner}is treated as encrypted and refused: schema load raises{kura, {unsupported_encrypted_type, Mod, Field}}, andcast/2,dump/2,load/2andto_pg_type/1raise{kura_crypto, unsupported_encrypted_type}. Before, such a type was not redacted by the audit trail, not refused by the filter guard, and loaded as its raw ciphertext.An
{encrypted, Inner}field whoseInnercannot be encrypted, such as{encrypted, float}, raises{kura, {unsupported_encrypted_type, Mod, Field}}when the schema is first read, instead of{kura_crypto, {not_encryptable, Inner}}at the first write.kura_types:load/2on an encrypted type loadsundefined, which kura_sqlite returns for NULL, asundefined, and raises{kura_crypto, malformed_frame}for any other non-binary value. Both crashed with afunction_clauseinformat_type/1before.Upgrading: the encrypted-field checks above and under Security refuse calls that used to be accepted. None of them could work on ciphertext, and none reads or changes stored data. Look for:
order_by/2,group_by/2,distinct/2, a windowpartition_byororder_by, orsum,avg,minormaxon an encrypted field or aselect_expr/2alias of one: sort, group or compute on the loaded rows instead.- A
joinoncolumn, a primary key, or an association key that is encrypted, including the owner-sidetarget_keyof ahas_manyorhas_one: key on a plain column. A schema with an encrypted key now fails to load. - An attribute tenant on an encrypted field:
update/2,delete/2and upserts now raise as queries did. Make the tenant column plain. - A conflict guard (
#{guard => [Field]}) naming an encrypted field: drop it from the guard. - A condition added before the
join/4,5orwith_cte/3that brings an encrypted field into scope: it now raises at the join or CTE, not only when added after it. {subquery, Q}as a comparison value, anin-list element or abetweenbound: useexists,not_existsor a single-columnin.{encrypted, Inner}with anInnerthat cannot be encrypted, or any other type taggedencrypted: the schema fails to load andto_pg_type/1raises{kura_crypto, unsupported_encrypted_type}, so no migration column is generated for it.{array, {encrypted, Inner}}keeps itsBYTEA[]column and data unchanged.
Application boot starts a repo's pool the way
kura_repo_worker:start/1does, throughkura_db:start_pool/1, from the configkura_repo:config/1returns (#197). Boot now applies the repo'sinit/1, loading the repo module first, and names the pool from thepoolkey. A repo configured withpool => Xgot a pool named after the repo at boot while its queries went toX, and connection settings set ininit/1were missing from the pool boot started. Boot still logs a pool that did not start and carries on;start/1returns the error.The legacy flat single-repo form (
{repo, _}with connection keys at the kura env level) takes itshost,port,passwordandpool_sizedefaults from the pool module instead of from kura at boot (#197). Boot filled inhost"localhost",port5432, an emptypasswordandpool_size10 thatstart/1did not, so the same config could start at boot and fail throughstart/1. Both now hand the pool module the settings as configured, asstart/1has done since #193, and kura_postgres applies the samehost,portandpool_sizedefaults. Theuseranddatabasedefaults stay for now; see Deprecated. The flat form also no longer passes areposmap in the kura env to the pool along with the connection settings. Requires the kura_postgres release containing kura_postgres#31.A repo
init/1that raises while its pool is started no longer stops kura's application start. The pool is not started, and only the shape of the reason is logged: an atom as it is, a tuple as{Tag, redacted}, anything else asredacted, sinceinit/1is the consumer's code and its reason may hold a secret it fetched.kura_repo_worker:start/1returns{error, {init_failed, {Class, Shape}}}. For a repo in thereposmap or the flat form,init/1runs during kura's own start, before the consuming application, so it must not call that application's processes.A repo's
init/1no longer runs on every query (#200). The pool start keeps the repo's own settings (dialect,pool,pool_module,driver_module,read_only,replicas,uuid_version) in apersistent_term, and the query-time lookups (kura_db:get_pool/1, the pool and driver module,kura_repo:read_only/1,replica/1, the dialect and the UUID version) read them from there. Aninit/1that reads a file or a vault does it once per pool start, and one that raises later no longer turns every query into that exception, with the config in the crash report. Connection settings and secrets are not kept. The settings change only when the pool is started again:kura_repo_worker:start/1on a running pool re-reads them. A start that moves the repo to another pool name and fails makes its queries raise{pool_not_started, Pool}instead of reaching the previous pool; a failed restart on the same pool, or a failinginit/1, keeps the previous settings. A repo whose pool kura did not start falls back to the old lookup, its config read andinit/1run on each call.kura_repo:config/1still reads the config afresh each call.A started repo's settings are a snapshot taken at pool start (#200). Changing its
read_only,replicas,uuid_version,dialect,pool,pool_moduleordriver_modulewithapplication:set_envno longer takes effect on the next query: queries keep the settings stored at pool start untilkura_repo_worker:start/1is called again. A repo whose pool kura did not start still sees the change on its next call.Upgrading:
read_onlyis captured when the repo's pool starts (#200). A started repo switched toread_only => trueat runtime, withapplication:set_envor byinit/1reading a flag, keeps accepting writes untilkura_repo_worker:start/1is called again for it. Callstart/1after changing it.Upgrading:
replicas,uuid_version,dialect,pool,pool_moduleanddriver_moduleare captured the same way (#200). A test or a release task that changes them withapplication:set_envon a started repo must callkura_repo_worker:start/1for that repo afterwards; a repo whose pool kura did not start still reads them on each call.Upgrading: two repos can no longer share one pool by naming the same
pool(#201). That includes a repo kura never started that only names another repo's running pool, such as a migration repo pointed at the application repo's pool. Give each repo its own pool name.A repo whose config names a pool another repo started is refused instead of sharing that pool, database and credentials (#201).
kura_repo_worker:start/1returns{error, {pool_owned_by, Owner}}, boot logs it as a pool that did not start and carries on, and the refused repo's queries raise{pool_owned_by, Owner}. The check is made before the pool module is called, so it holds for a pool module that answers{ok, Pid}for a name already running, askura_pool_minatodid. The repo that started a pool can start it again and getsok. A pool already running that kura did not start goes to the first repo that starts it, with a warning naming the repo, the pool and the pool module, since it keeps the connection settings it was started with. Changing a running repo's credentials takeskura_db:stop_pool/1and thenkura_repo_worker:start/1;start/1alone returnsokand leaves the pool as it is. A pool stays owned by the repo that started it untilkura_db:stop_pool/1releases it, or until that repo starts on another pool name and the old pool has stopped; a pool stopped outside kura stays owned. A repo whose pool name another repo owns cannot query it either:kura_db:get_pool/1raises{pool_owned_by, Owner}, which covers a repo kura never started and one stopped withkura_db:stop_pool/1whose pool name another repo then started. A repo that starts on another pool name keeps the pool it had until that pool is stopped, which happens right after the new one starts, so no other repo can adopt it while it runs with the first repo's credentials. Two such starts of one repo at once leave it on one of the two new pools and stop the other. If a stop raises, the start still returnsok, the failure is logged with only the shape of its reason, and that pool stays owned.kura_db:stop_pool/1stops every pool the repo still owns, one whose stop raised or whose start died before stopping it among them; a pool whose stop raises there is logged the same way and stays owned, and the others are still stopped.The many_to_many join-table SQL, the preload read and the
put_assoc/cast_assocDELETE and INSERT, is compiled by the repo's dialect (to_sql/1,delete_all/1,insert_all/3) instead of written by hand with Postgres$Nplaceholders and quoting (#153). A dialect with other placeholders or identifier quoting gets its own SQL for join tables; on kura_sqlite the join table now uses?N. The join read runs throughkura_db:query/3rather thankura_repo_worker:pgo_query/3. Join-table SQL is still qualified by a prefix tenant and not scoped by an attribute tenant.The dialect callbacks accept a table named by a binary: the new
kura_dialect:table()type,atom() | module() | binary(), covers the table argument ofinsert,update,deleteandinsert_all, and thefromof the join-table query handed toto_sql/1anddelete_all/1(#153). Ajoin_throughgiven as a binary reaches the dialect that way.kura_query:from/1and the repo's query functions still take a schema module or an atom.kura_dialect_pgreturns a binary table name as it is; a dialect that resolves the table itself rather than delegating to it must do the same.The migrator takes its advisory lock with
pg_try_advisory_xact_lock, retried in a fresh transaction everymigration_lock_retry_intervalmilliseconds (default 100), instead of blocking inpg_advisory_xact_lock(#139). A node waiting inside a statement, or inside one long transaction, is a transaction thatCREATE INDEX CONCURRENTLYon the lock holder waits for, and the two deadlocked.Upgrading: deploy this kura on every node before shipping the first
transactional() -> falsemigration. A node still on an older kura waits for the lock the blocking way, which deadlocks with a concurrent index build on the node holding it, and it ignorestransactional/0andconcurrently, so if it runs the migration itself it builds the index with a plainCREATE INDEXthat blocks writes to the table.A
schema_migrationsread that fails stopsmigrate/1,rollback/1,2,3andfake/1,2,3with{error, {schema_migrations_unreadable, Reason}}, where it was taken as an empty table (#139). A non-transactional migration's re-read failing, on alock_timeoutfor instance, would otherwise run an applied migration again in autocommit.status/1still reports such a table as nothing applied.The migrator keeps only a Postgres error's
code,message,severity,hint,schema,table,column,data_typeandconstraintin what it logs, returns and emits as telemetryerror_reason(#139). A failedCREATE UNIQUE INDEXput the duplicated key values, often personal data, indetail.The
[kura, migrator, migrate, stop]event carries the newapplied_versionsmetadata, and on an error itsapplied_countandapplied_versionsgive the migrations a split run committed before it failed, which stay applied, whereapplied_countwas always 0 (#139).A migrator waiting for the advisory lock logs a warning every 30 seconds with the time it has waited, where the wait was silent after its first info line (#139). The wait is still unbounded by default; the new
migration_lock_timeoutapp env (milliseconds, defaultinfinity) ends it with{error, migration_lock_timeout}frommigrate/1,rollback/1,2,3,fake/1,2,3andensure_schema_migrations/1. Any role able to connect can hold the shared lock key and stall deploys, so set a finite timeout in production.migration_lock_retry_intervalbelow 10 ms is taken as 10, where 0 busy-looped.Inside
kura_db:transaction/2or with a sandbox connection checked out, the migrator tries the advisory lock once and returns{error, migration_lock_busy}when another session holds it, where it polled inside the enclosing transaction (#139).kura_repo_worker:start/1returns{error, Reason}when the pool does not start, where it logged the failure and returnedok(#192). A test setup written asok = kura_repo_worker:start(my_repo)now stops at the failure. Secrets inReasonare replaced byredacted. Application boot still logs a pool that did not start and carries on.kura_repo_worker:start/1hands the connection settings in the repo's config to itspool_module, the way application boot does, instead of building a Postgres-shaped config with defaults for host, port and user (#193). Akura_sqliterepo started this way gets its own defaults,:memory:among them, where it raised{missing_repo_config, database}. A Postgres repo in thereposmap or the per-app form that left outusernameand relied on thepostgresdefault must now set it. With kura_postgres from this release on, the pool refuses to start with{missing_option, user}andstart/1returns the error. A missingdatabaseno longer raisesmissing_repo_config: minato connects to the database named after the user, as libpq does. The flat form on Postgres keeps itsuseranddatabasedefaults for now; see Deprecated.The query cache keys on a query's shape, with bound values replaced by markers, instead of on the whole query term (#163).
get(User, Id)now holds one entry however many ids it is called with, where it held one per id. Compiling a query with distinct values drops from 2.8 to 0.7 us for a lookup by id and from 7.2 to 3.0 us for a filtered page. The trade-off: a query repeated with the very same values, which used to be a whole-query hit, now pays for splitting and binding, from 0.5 to 0.7 us for the lookup and from 0.8 to 3.0 us for the filtered page. A dialect must pass bound values through to the parameter list untouched; seekura_dialect.{Field, '=', Value}always bindsValue. It used to be dispatched as{Field, Value}, so{status, '=', is_nil}compiled toIS NULL.A row-value
inwhose tuples do not match the column count raises{row_arity_mismatch, Arity, Tuple}. It used to drop or shift values between rows.Building
in/not_inand row-valueinplaceholders is linear in the list length; it was quadratic.
Security
kura_keyring_envraises{kura_crypto, invalid_keyring_config}when theencryptionconfig is not a map or itskeysis not a proper list. It used to raise abadmaporbadargwhose reason or stack arguments held the whole config, base64 keys included, on any encrypted read, write or lookup.- The filter guard on
{encrypted, _}fields could be bypassed (found while designing #137).kura_query:where/2only refused an encrypted field when it was the first element of the condition, andhaving/2did not check at all.{'not', {ssn, V}},{[ssn], in, [{V}]},{[id, ssn], in, [{1, V}]}andhaving(Q, {ssn, V})were accepted and sent the plaintext to the server as a bind parameter and into the telemetry and logparams; thenotform also matched every row. Both functions now walk the whole condition (and,or,not,in, row-valuein,between, every comparison operator,insubqueries) and raise{kura, {encrypted_field_in_where | encrypted_field_in_having, Field}}on any comparison of an encrypted field to a value. Fields of joined schemas are checked too, including conditions added before the join, and so is the attribute-tenancy condition. On a schema with encrypted fields, a condition shape the guard does not recognise raises{kura, unrecognised_condition}.{fragment, SQL, Params}is still not inspected. - An
{array, {encrypted, Inner}}field, at any array depth, was not recognised as encrypted:kura_types:encryption/1returnednone, so the audit trail stored its elements in plaintext and the filter guard let a condition bind them. It is now recognised as encrypted ({ok, #{inner => Inner, array => Depth}}), so it is redacted, refused in filters, ordering and aggregates, and refused as a key or embed field like any other encrypted field. Its storage is unchanged: each element encrypted, in aBYTEA[]column. - An attribute tenant on an encrypted field was refused on queries but not
on
updateanddelete, which add the tenant to the key clauses directly and bound its plaintext. They now raise{kura, {encrypted_field_in_where, Field}}too. - An upsert (
insert/3orinsert_all/4with anon_conflictother thannothing) under an attribute tenant on an encrypted field guarded the conflict update withtable.Field = EXCLUDED.Field, which compares two ciphertexts with different nonces, so it silently never updated. It now raises{kura, {encrypted_field_in_where, Field}}, from the same check update and delete use. - A caller-supplied conflict guard on an encrypted field,
{Target, Action, #{guard => [Field]}}, never updated for the same reason. It now raises{kura, {encrypted_field_in_conflict_guard, Field}}. Anothingaction compiles no guard and is not refused, with or without options. - A correlated subquery bypassed the filter guard. In
{exists, {subquery, Sub}}or{Field, in, {subquery, Sub}}on a query over an encrypted schema, a condition inSubnaming an outer encrypted field thatSub's own schemas do not declare was not checked, and the database resolved the unqualified name to the outer column, binding the plaintext. The guard now walks subquery conditions (wheres, havings, union branches, nested subqueries) against the outer encrypted fields they do not shadow. A bare-table source shadows nothing. - A
{subquery, Q}anywhere butexists,not_existsor a single-columnin, such as{id, '=', {subquery, Q}}, anin-list element or abetweenbound, now raises{kura, unrecognised_condition}on every query. The dialect never compiled it there; it was bound as a parameter value. - A CTE bypassed the filter guard. A
fromorjoinnaming a CTE over an encrypted schema had no encrypted fields in scope, sowhere(from(enc_cte), {ssn, V})bound the plaintext, as did a condition added beforewith_cte/3. A source now gets the encrypted fields of every CTE its name, or its schema's table name, resolves to, including aliases a CTE selects an encrypted field under and the columns of its union, intersect or except branches (by position, under the first query's names; every column when aSELECT *hides the positions), andwith_cte/3andjoin/4,5re-check the conditions already in the query, its CTE bodies and its union branches. A name shared by several CTEs, or by a CTE and a schema, gets the encrypted fields of all of them. - A
has_manyorhas_onewhose#kura_ref{target_key = Cols}names an encrypted field of the owner was not refused. Preloading bound the decrypted owner value in the child query, and writes copied it into the child's foreign key in clear. Schema load now raises{kura, {encrypted_association_key, Mod, Assoc, Field}}. - On a query with encrypted fields in scope, an improper list under
and,oror a row-valueincrashed the filter guard with afunction_clausewhose arguments carried the plaintext, and anandororover a non-list was accepted. Both now raise{kura, unrecognised_condition}. - The filter guard ran only in the builder functions, so a
#kura_query{}record built by hand, or updated afterwhere/2(for example a newfrom), compiled with the plaintext bound.kura_query_compiler'sto_sql/2,to_sql_cached/2,to_sql_from/3,update_all/3anddelete_all/2now runkura_query:check_encrypted/1over the whole query (wheres, havings, subqueries, CTE bodies, union branches) before compiling.to_sql_cached/2runs it on a cache miss only: the guard reads nothing the shape key replaces, so a hit means a query of the same shape already passed. A query the shape split cannot take apart goes throughto_sql/2and is never cached. A hit costs what it did before the guard (cached get-by-id inkura_query_cache_bench: 0.76 us before, 0.98 us with the guard on every call, 0.74 us on a miss only; filtered page: 3.00, 3.46, 3.12 us). The other entry points pay about 70 ns per call. - Starting a pool hands the pool module the connection settings only.
The repo's own settings, the
encryptionkeyring among them, were passed along with them, and a pool module that echoed its options in an error put the keys in the log. A pool error that echoes anencryptionorkeyringkey, in a map or a key-value list, now has its value replaced byredacted, likepassword. A password given as an improper list no longer raises with the password in the stack trace. - Attribute tenancy (
{attribute, {Field, Value}}) leaked reads. Only the top level of a query was filtered, so a union, CTE orin/existssubquery read other tenants' rows, and aggregates and streams were not filtered at all. The condition is now added by the compiler, to every nested query. - Attribute tenancy leaked writes.
update/2anddelete/2, including the optimistic-lock path, matched a record by key alone; an update with only association changes wrote them onto whatever record it was given; and a change to the tenant field moved a row to another tenant. Record writes now carry the tenant in their key, such an update checks the record first, and the tenant field is pinned. - Attribute tenancy leaked through inserts.
insert_allandinsert/3did not stamp the tenant, and an upsert could overwrite another tenant's row. Inserts are now stamped, and an upsert only updates a row of the same tenant. - Preloading two or more associations ran each one in a new process,
which has no tenant. Under attribute tenancy a
belongs_towhose foreign key the caller set returned another tenant's row; under prefix tenancy the preload read the connection's default schema. The preload processes now carry the caller's tenant. kura_tenant:put_tenant/1stored any term, and one that was not a strategy read back as no tenant, so a typo such as{prefix, "acme"}turned scoping off. It now raises{invalid_tenant, Tenant}. An attribute value ofis_niloris_not_nilis refused too: the condition read it as a null test, sois_not_nilmatched every tenant.- Prefix tenancy (
{prefix, Schema}) ran the optimistic-lock update and many-to-many join tables on the search_path. Where two tenants' rows share an id, one tenant could update the other's row and replace or read its links. Both are now qualified with the tenant's schema. - Upgrading: a scoped query whose table lacks the tenant field now
fails, as do
update/2,delete/2and upserts on such a table, and an invalid tenant raises. See the multitenancy guide for what is and is not scoped. kura_migrator's DDL identifier quoting now doubles an embedded double quote, matching the fixkura_dialect_pg,kura_preloaderandkura_repo_workeralready carry. It was the last unhardened copy of that helper.- Column defaults are escaped before being spliced into DDL. A default
containing a single quote previously closed the literal early and
produced broken or attacker-shaped SQL. Both emitters are fixed -
kura_dialect_pg:format_default/1, which runs whenever a dialect is configured, andkura_migrator's fallback. kura_query:where/2raises on an{encrypted, _}field. Encryption uses a random nonce, so a freshly encrypted value never equals the stored ciphertext: the condition could never match, and it shipped the plaintext to the server as a bind parameter, intopg_stat_statementsand the query log.
Fixed
kura_types:cast/2on an empty time (~"",~"2024-01-01T") raisedbadarg; it now returns a cast error, so a changeset gets a field error.A
utc_datetimewith an offset other thanZdropped the offset, so~"2024-01-01T10:00:00+02:00"was stored as 10:00 UTC. The offset (+HH:MM,+HHMMor+HH) is now applied, giving 08:00 UTC; a malformed one is a cast error. Anaive_datetimeand atimekeep their wall-clock value, as before.A time fraction longer than nine digits is refused, and the digits are checked over the binary, so a very long fraction no longer allocates a list of its bytes.
A parsed datetime is normalised through gregorian seconds, so
24:00:00and a leap second (:60) become the next day or minute, the value a read returns. Atimekeeps{24, 0, 0}.In a sandboxed test, a
COMMIT,ENDorROLLBACKrun through a query raises{DriverMod, transaction_ended_by_statement}with a driver that checks for it, and so does every later statement on that sandbox connection, from any process sharing it, without being run (#198). Akura_db:transaction/2whose function caught that error raises it too, rather thantransaction_rolled_back.kura_driver:query_on/4takes atransactionoption (startsorinside) for this; a driver that ignores it behaves as before. The driver contract now namestransaction_ended_by_statementas the error for every statement after a statement ended the transaction.The compiled-query cache replaces select-expression fragment parameters with markers. They stayed in the shape, so every new value interned another entry.
The query cache's entry-size and memory limits count the bytes of off-heap binaries. Neither
erts_debug:flat_size/1norets:info(Tab, memory)sees them, so an entry holding a large binary counted as a few words.kura_types:cast/2,dump/2andload/2crashed withfunction_clauseinstead of returning{error, _}when the error message had to name a{vector, N}type or an encrypted type, for example an{array, {encrypted, string}}given a non-list. The message names only the type, never the value.insert_all/3,4honouron_conflict. The option was silently dropped and a plain INSERT emitted, so a bulk upsert failed on the unique constraint instead of upserting, and the partial-index conflict target was unreachable from the bulk path. TheDO UPDATESET list is built fromEXCLUDED, because one clause applies to every row.kura_schema_verifymatches a declared index by what it is instead of by the generated<table>_<cols>_indexname: the same key columns in order, and for a unique declaration a valid unique index that is partial exactly when the declaration is. A plain declaration is also satisfied by a unique index, and a partial one by a full index. An index created under a custom name, renamed since, or added asADD CONSTRAINT ... UNIQUEno longer reports asmissing_index. A partial index's predicate is not compared, since PostgreSQL stores its own rewrite of theWHEREtext.Upgrading:
verify/1,2can report drift on a database that passed before, so a readiness probe built on it may turn unready after the bump. Each new report is real: an index under the generated name over the wrong columns, withoutUNIQUE, partial where the declaration is not, or left invalid by a failedCREATE INDEX CONCURRENTLY, which PostgreSQL ignores, forON CONFLICTtoo.
Deprecated
- The
useranddatabasedefaults of the legacy flat single-repo form on Postgres (#197). When the kura env sets{repo, Repo}, has noreposmap and the dialect iskura_dialect_pg, auser(when nousernameis set either) ordatabasethe config leaves out is still set to"postgres"when the pool starts, at boot and throughkura_repo_worker:start/1alike, and a warning names the keys filled. Kura 3.0 removes the fill, so set both keys. A repo in thereposmap or the per-app form gets no fill: kura_postgres needs itsuser, and withoutdatabaseit connects to the database named after the user, as libpq does. kura_app:pool_config/0andkura_app:pool_config/1. Usekura_repo:config/1. They now return the repo's whole config as its pool is started,dialectandpool_moduleincluded, with the flat form's deprecateduseranddatabasefill and no other defaults (#197). Both now apply the repo'sinit/1, and raise{init_failed, {Class, Shape}}when it raises, with only the shape of the reason kept.pool_config/1of a repo configured nowhere returns#{}, where it returned the flat kura env, with Postgres defaults on that dialect, andpool_config/0returns#{}when the kura env has norepo.kura_preloader:quote_table_bin/1. The dialect quotes and qualifies join tables now (#153).kura_schema_verify:declared_index_name/2. Callkura_migration:index_name/2, which it wraps.
Added
- Encryption v2 ciphertext frame, bound to its column (#137):
<<2, Mode:8, KeyId:16, IV:12, Tag:16, CT>>, Mode0(randomized). Each value is encrypted under a per-column subkey, HKDF-SHA256 of the root key with the context{Table, Column}(the schema's unprefixedtable()and the column name), and the context, mode and key id are authenticated as AAD. A v2 value copied to another encrypted column or table raises{kura_crypto, {bad_tag, KeyId}}on load instead of decrypting as that column's value. Subkeys are derived per operation, never cached. The repo read path (kura_db:load_row/2) reads v1 and v2. Writes stay v1 unless{kura, [{encryption_write_format, v2}]}is set, so a rolling deploy can upgrade every node before any node writes v2; a later release makes v2 the default. An existing v1 value stays v1 until that field is written again. Renaming the table or the column makes its v2 values undecryptable. See the README and the rolling deployments guide. - Not covered yet: every encrypted column still accepts v1 frames on
read, and a v1 frame is bound to nothing, so a v1 ciphertext copied into
a column decrypts there; the binding is complete only once v1 reads are
refused. Neither the row nor the tenant (prefix or attribute) is bound,
so ciphertexts can be swapped between rows or tenants of the same
column, and the elements of an encrypted array reordered or spliced
within it. An encrypted column of a joined schema comes back
undecrypted. When it shares a name with an encrypted
fromfield, a join without aselectreads the joined value under that field: a v2 value raises, a v1 value decrypts and is returned as thefromfield. - Cost per value, on one machine (
KURA_BENCH=1 rebar3 eunit --module=kura_crypto_bench): v1 encrypt 1.9-2.0 us and decrypt 1.1 us; v2 encrypt 4.8-4.9 us and decrypt 3.8 us, the difference being the per-call HKDF subkey.kura_db:load_row/2on a schema without encrypted fields went from 1.45-1.49 us to 1.53-1.63 us per row. kura_types:dump/3andload/3take the column context{Table, Column}, andkura_schema:encryption_specs/1returns#{Field => #{context => {Table, Column}}}for each stored encrypted field. The insert, update,update_all,insert_alland row-loading seams use them.dump/2raises{kura_crypto, no_context}for an encrypted value when the write format isv2, andload/2raises it on a v2 frame, rather than guessing a context.kura_cryptogainsencrypt/2,decrypt/2andwrite_format/0; an invalidencryption_write_formatfailskuraapplication start with{kura_crypto, invalid_write_format}. A frame version other than 1 or 2 raises{kura_crypto, {unsupported_version, V}}, an unknown v2 mode{kura_crypto, {unsupported_mode, Mode}}, an invalid context{kura_crypto, invalid_context}, and a non-binary plaintext{kura_crypto, malformed_plaintext}. A keyring key that is not 32 bytes now raisesno_active_keyor{unknown_key_id, KeyId}for v1 as well.kura_schemarefuses two encrypted fields stored in the same column ({kura, {duplicate_encrypted_column, Mod, Column}}) and an encrypted field whose column name is not a binary of 1 to 65535 bytes ({kura, {invalid_encrypted_column, Mod, Field}}), the first time it reads the schema. An array of encrypted values that loads a non-list raises{kura_crypto, malformed_frame}instead of returning an error, which the read path turned into the raw value.- Non-transactional migrations (#139). A migration exporting
transactional() -> falseruns outside a transaction, statement by statement, on one connection holding the session-level advisory lock. Its version is recorded only after its last statement succeeds: a failure part-way leaves the earlier statements committed and the migration pending, and the error log says how many statements were committed. Transactional migrations before it in the run commit first, and those after it run in further transactions, each under the lock. Insidekura_db:transaction/2or with a sandbox connection checked out, a run with one pending is refused with{non_transactional_in_transaction, Version, Module}before anything executes. See the upgrade note under Changed before shipping one. {create_index, ...}takesconcurrently => true(orconcurrentlyin the list form) and emitsCREATE INDEX CONCURRENTLY(#139). It is refused in a migration that is still transactional, with{concurrently_in_transaction, Version, Module}, before anything in the run executes. On a non-Postgres pool that does not declare the new standardconcurrent_indexescapability (SQLite) it compiles to a plainCREATE INDEX. A Postgres repo on a pool without it (kura_postgres 1.1.3 and earlier) is refused with{concurrent_indexes_unsupported, PoolModule}while the run is planned; non-transactional migrations need kura_postgres 1.1.5 or later.kura_db:query_on/4,5runs a statement on a connection the caller checked out, with the same telemetry askura_db:query/3./5hands an options map to the driver'squery_on/4(timeoutfor minato).kura_repo:settings/1returns a repo's own settings as queries see them, without connection settings or secrets (#200).kura_db:stop_pool/1stops a repo's pool through its pool module, releases the pool name and drops the repo's stored settings (#201).- The
kura_poolcontract states thatstart_pool/2on a name already running returns{error, {already_started, Pid}}. kura_query:check_encrypted/1, the filter guard over a whole query.kura_types:encryption/1, the one place that recognises an encrypted type. It returnsnone,unsupportedor{ok, #{inner => Inner}}, witharray => Depthfor an array of an encrypted type; the spec is a map so later options can be added as keys. The filter guard, audit redaction, schema validation and the type seams all use it.kura_types:encryptable_inner/1, whether a type can be theInnerof{encrypted, Inner}; schema validation uses it.kura_hkdf, HKDF-SHA256 (RFC 5869) overcrypto:mac/4, with the RFC test vectors. Not used yet, and hidden from the docs until it is; groundwork for per-column keys (#137).expand/3refuses a PRK shorter than 32 bytes with{kura_hkdf, short_prk}, and both functions raise{kura_hkdf, badarg}on a non-binary key, salt or info or a non-integer length, so no key material reaches a crash report.- A corpus of v1 ciphertexts under fixed test keys that every release must keep decrypting.
kura_schema:is_schema/1andkura_schema:encrypted_fields/1, both memoised.is_schema/1replaces three hand-rolled copies of the samecode:ensure_loaded/1+function_exported/3check, whose negative answer cost acode_serverround trip on every call.- Version-scoped baselining.
kura_migrator:fake(Repo, UpTo)stamps only the pending migrations at or below versionUpTo, so a partial brownfield adoption can baseline the introspected prefix and letmigrate/1create the genuinely new tables.fake/3does the same for one application of a multi-application repo.UpTomust be the version of a discovered migration, so a mistyped timestamp stamps nothing instead of everything (#156). kura_schema:forget/1drops a module's memoised schema lookups and flushes the compiled-query cache, for tools that reload schema modules in one VM. The cache never expired before, so a reloaded module kept answering with the old module's key and associations (#169).kura_query:distance(Field, Metric, Vector)for pgvector nearest-neighbour search (#122). Metrics arel2,cosineandinner_product, emitted as<->,<=>and<#>; a smaller value is nearer for all three. A distance goes inorder_by/2, whose spec widens from{atom(), Dir}to{atom() | distance(), Dir}, and inselect_expr/2.ORDER BYnow carries bind parameters, numbered afterHAVINGand beforeLIMIT. The vector is cast and dumped to text when the distance is built, and the query must befrom/1a schema in which the field is avectoror{vector, N}of matching dimension. A distance inwhere/2,having/2,group_by/2,distinct/2,select/2(and the aggregate helpers),count/2, ajoincolumn orover/2raises{kura, {distance_not_supported_here, Clause}}, in a condition also as a list element or abetweenend. A vector over 16000 dimensions raises, and every compiler entry point applies the same checks to a#kura_query{}written by hand. No error reason carries the query vector. Requires pgvector >= 0.8.2 (CVE-2026-3172). The query builder guide covers search-time settings (SET LOCAL hnsw.ef_searchin a transaction) and leavesCREATE EXTENSIONto the cluster bootstrap.
Added
- Multi-application migration discovery. A repo names further
applications shipping migrations through the optional
kura_repocallbackmigration_apps/0; the owning application is always included. Applications are ordered by their OTPapplicationslists, so a dependency's migrations run before its dependents'. Noappcolumn and no schema change - existing repos are unaffected. kura_migrator:migration_apps/1returns the resolved, dependency ordered application list for a repo.kura_migrator:rollback/3andkura_migrator:fake/2take the application to operate on, for repos drawing migrations from more than one.rollback/3's window is confined to the named application's applied versions;fake/2leaves every other application's migrations pending.
Security
update_all/2wrote plaintext into{encrypted, _}columns. It was the only write path that never dumped values through the schema, so a value bound for an encrypted column reached the driver unencrypted and was stored in the clear. Every other write path (insert,update,insert_all) encrypted correctly. Any row whose encrypted column was last written byupdate_all/2holds plaintext and needs rewriting. A value is ciphertext if and only ifkura_crypto:decrypt/1does not raise on it; the frame is<<Version:8, KeyId:8, Nonce:12/binary, Tag:16/binary, Cipher/binary>>, so in practice a stored value under 30 bytes, or one whose first byte is not the frame version, is plaintext. No known consumer is affected - no repo depending on kura declares an{encrypted, _}field.- CTE names passed to
kura_query:with_cte/3and the many-to-many join-table name are now quoted, andquote_ident/1doubles an embedded double quote. A consumer deriving any of those from request data could previously break out of the quoting and inject SQL. No identifier kura itself renders was affected - all of them come from developer-supplied atoms.
Fixed
- A binary written to a
jsonbfield is no longer double-encoded.kura_types:dump/2encoded every binary as a JSON string scalar, so an already-serialised document was stored as a quoted string:->,->>and@>against it all returned NULL, and a predicate shapedWHERE NOT (policy @> '...')failed open. A binary that parses as a JSON object or array is now stored as the document it is; anything else is still encoded as a string, which keeps theload/2round trip intact for stored JSON string scalars. This affectedinsertandupdateas well, not only the bulk paths. - The atom
nulldumps to SQL NULL for every type, matchingundefined. It previously reached the driver raw through the fall-open seam, which also meant{enum, _}stored the literal string"null". - Writes fail closed when a value cannot be dumped. Previously the raw
undumped value was handed to the driver, which turned a deterministic
type error into a driver-level
badargor, for a value the server happened to accept, a silent write of the wrong thing. Changeset paths add the error to the changeset;insert_all/2,3andupdate_all/2return{error, {dump_failed, Field, Message}}. - A migration version claimed by two modules is now
{error, {duplicate_migration_version, [{Version, [{App, Module}]}]}}instead of a partially-applied batch failing on theschema_migrationsprimary key. - The applied-version set is read inside the migration advisory lock. Two nodes booting together could both see the same migration as pending; the loser then failed its whole batch on a duplicate key.
rollback/2no longer skips applied versions that no migration module claims. It used to roll back fewer migrations than asked while reporting success, and ran the survivingdown/0s across the gap. Those versions are now named in{error, {unknown_applied_versions, Versions}}and nothing runs. Versions outside the rollback window are unaffected.- Rollback runs in reverse apply order rather than descending version
order, so a dependency's
down/0never runs before its dependents'. Unchanged for a single-application repo, where the two coincide. schema_migrationsis created under the migration advisory lock, in a transaction of its own.CREATE TABLE IF NOT EXISTSis not atomic against a concurrent creator, so two nodes booting together could both pass the existence check and the loser fail onpg_type's unique index.- The
CREATE TABLEresult is no longer discarded. A database that refuses the statement now gives{error, {schema_migrations_failed, Reason}}rather thanokfollowed by every later query failing on a missing table.
Changed
update_all/2dumps its SET map through the schema's field types whenever the query source is a schema module, matchinginsertandupdate. Ajsonbmap or any other non-primitive is now serialised rather than reaching the driver raw.- The bulk write paths accept values in the form
cast/2accepts, not only the formdump/2accepts.insert_all/2,3andupdate_all/2take raw maps rather than cast changesets, so~"admin"for an enum or~"2026-01-01"for a date now casts before dumping instead of failing. The cast only runs after a dump attempt fails, so the happy path is unchanged.{encrypted, _}fields are the exception: they raise on a bad value rather than casting, so that a crypto failure can never be treated as recoverable. A type module that does not load raises too - the fail-closed contract covers invalid data, not a broken deployment. on_conflictaccepts{{columns, Cols, #{where => Predicate}}, Action}, emittingON CONFLICT (cols) WHERE predicate. Tables using partial unique indexes can now express a single-statement upsert;ON CONFLICT ON CONSTRAINTcannot name a partial index. The predicate is raw SQL, spliced verbatim - it must be a trusted literal matching the index definition. An options map carrying anything other than a binarywherenow raises rather than silently emitting no predicate, which would let PostgreSQL infer a different unique index.kura_migrator:status/1may now return{error, Reason}when discovery fails, and lists migrations in apply order. Unchanged for a single-application repo.kura_migrator:rollback/1,2andkura_migrator:fake/1refuse a repo drawing migrations from more than one application, with{error, {ambiguous_rollback, Apps}}and{error, {ambiguous_fake, Apps}}. Both choose a set of versions with no regard for which application shipped them, which across applications half-migrates several unrelated ones - or, forfake/1, stamps a freshly installed extension's tables as created when they do not exist, after whichmigrate/1never creates them. Userollback/3andfake/2. A repo withoutmigration_apps/0is not a multi-application set and is unaffected.kura_migrator:ensure_schema_migrations/1returnsok | {error, term()}rather than alwaysok.
[2.0.0] - 2026-05-10
The 2.0 line introduces pluggable backends and multi-repo support. The intermediate 2.1-2.5 dev tags were rolled into this release; nothing shipped to Hex during that window. See MIGRATION-2.0.md for upgrade notes.
Added
Pluggable backends. Pick a backend package and point kura at it with
{backend, ...}. Kura auto-populatesdialect,pool_module, anddriver_modulefrom the aggregator at app start.kura_poolbehaviour - connection-pool contract.kura_capabilitiesbehaviour - backend feature flags (e.g.advisory_locks,returning,arrays).kura_dialectbehaviour - SQL dialect contract, with optionalcolumn_type/1andformat_default/1callbacks for backend-specific DDL.kura_driverbehaviour - query/transaction driver contract.kura_pool_ets- in-memory pool for tests that don't need a real DB.
Multi-repo configuration. Run two or more repos in the same app, each with its own backend, dialect, and pool. Configure with a map of maps under
{repos, ...}:{kura, [ {repos, #{ primary => #{ backend => kura_backend_postgres, host => "primary.example.com", database => "main", pool_size => 10 }, analytics => #{ backend => kura_backend_sqlite, database => <<":memory:">> } }} ]}Kura starts each repo's pool on app start. The dialect resolves per-repo, so
primaryemits Postgres SQL whileanalyticsemits SQLite SQL. The query cache is keyed per repo so dialects never share entries.kura_app:pool_config/1returns the config map for a specific repo.kura_types:cast(boolean, 0|1)so SQLite (booleans stored as INTEGER) round-trips cleanly.
Changed
kura_query_compiler:to_sql/2,to_sql_cached/2,to_sql_from/3,insert/4,insert/5,update/5,delete/4,update_all/3,delete_all/2,insert_all/4,insert_all/5, anddialect/1takeRepoModas the first argument so they can resolve the per-repo dialect. Internal callers (kura_repo_worker,kura_stream,kura_migrator) thread the repo through automatically.kura_query_cachekeys are tuples{RepoMod, QueryHash}. The cache ETS table is now owned by a supervised gen_server so it survives any caller exiting.kura_db:query/3and the rest of the query path route throughkura_pool/kura_driver, so backends are swappable.kura_app:pool_config/0is dialect-aware. PG-shaped defaults (port 5432, user/database"postgres", decode_opts) only apply whendialectiskura_dialect_pg. Other dialects get a pass-through map of user-set kura env keys.kura_app:configure_pg_types/0only runs whendialectiskura_dialect_pg.kura_repo:read_config/1returns a pass-through map of all kura env keys (minus bookkeeping). Previously hardcoded the PG-shaped subset and silently droppedpool_module,driver_module,backend.kura_migratorskipspg_advisory_xact_lockwhen the configured pool doesn't declare theadvisory_lockscapability. The migration transaction alone serializes runs on backends that lack advisory locks (SQLite, etc.).- Single-repo legacy config (flat
kuraenv keys) and the per-app form (application:get_env(OtpApp, RepoMod)) keep working unchanged. The globalapplication:get_env(kura, dialect)is consulted as a fallback when a repo's config map omitsdialect.
Removed (BREAKING)
kura_pool_pgo,kura_driver_pgono longer ship inkura. Installkura_postgresfor Postgres orkura_sqlitefor SQLite.pgois no longer a runtime dependency ofkura.kura_dialect_pgremains in core as the default ANSI-ish SQL emitter that other dialects delegate to.kura_query_compiler:dialect/0no longer defaults tokura_dialect_pg. Usedialect/1and configure the dialect per repo (recommended via{backend, ...}), or set the globalapplication:set_env(kura, dialect, Module)for legacy single-dialect setups.kura_db:get_pool_module/1andget_driver_module/1error with{no_pool_module_configured, _}/{no_driver_module_configured, _}when not configured. Set{backend, ...}(recommended) orpool_module/driver_moduleexplicitly.
[1.8.0] - 2026-03-06
Changed
- Breaking:
kura_repobehaviour now requiresotp_app/0callback instead ofconfig/0- database configuration is read from application environment viaapplication:get_env(OtpApp, RepoModule) - Optional
init/1callback onkura_repo- modify config at runtime (read secrets from env vars, files, external services) kura_repo:config/1function reads config from app env, then callsinit/1if defined- All internal
get_pool/1calls now usekura_repo:config/1instead ofRepoMod:config()
[1.7.0] - 2026-03-06
Added
telemetrylibrary integration - every query emits a[kura, repo, query]telemetry event with measurements (duration,duration_us) and metadata (query,params,repo,result,num_rows,source)build_telemetry_metadata/4andextract_source/1exported fromkura_repo_workerfor testingsourcefield in telemetry metadata - table name extracted from the SQL query
Changed
- Legacy
{kura, [{log, ...}]}config still works but now runs alongside telemetry events (not instead of)
[1.6.0] - 2026-03-06
Added
- Ecto-style index support -
indexes/0optional callback onkura_schemafor declaring indexes at the schema level - Map-based
{create_index, Table, Cols, Opts}migration operation with auto-generated index names ({table}_{cols}_index) kura_migration:index_name/2helper for generating Ecto-style index names- Unique indexes declared via
indexes/0auto-register changeset constraints - no manualunique_constraint/3calls needed - New types:
index_def(),index_opts_map()inkura_migration
[1.5.0] - 2026-03-05
Added
- Table-level constraints in migrations -
{create_table, Table, Columns, Constraints}4-tuple variant supporting{unique, [atom()]}and{check, binary()}inline constraints constraints/0optional callback onkura_schemabehaviour - declares table-level constraints on the schema- Auto-registration of schema constraints on
kura_changeset:cast/4- duplicate inserts get friendly error messages without manualunique_constraint/3calls
[1.4.0] - 2026-03-05
Changed
- Breaking: Minimum OTP version is now OTP 28 (sigil syntax, ELP fixes)
- Binary string literals converted to sigil syntax (
~"...") across changeset modules - Eliminated unnecessary intermediate list and tuple allocations in association casting
[1.3.2] - 2026-03-05
Fixed
Dialyzer warnings in
get_field/2,3-maps:find/2returns{ok, V} | error, not map patterns- Atom exhaustion risk in enum
load/2- now validates against declared values list instead ofbinary_to_atom - Atom exhaustion risk in
kura_repo_workererror handlers - NOT NULL and constraint errors fall back tobaseatom for unknown columns - CI running resilience tests that require docker compose control - explicitly list test modules
Added
- Production readiness test suites:
kura_stress_tests(7 concurrency tests),kura_bench_tests(6 throughput benchmarks),kura_migration_stress_tests(4 migration safety tests),kura_resilience_tests(4 failure/recovery tests) - Makefile targets:
test-stress,test-bench,test-migration-stress,test-resilience,test-production
[1.3.1] - 2026-03-04
Fixed
- Advisory lock query wrapped to avoid pgo void type decode error (
pg_advisory_xact_lockreturns void)
[1.3.0] - 2026-03-03
Changed
- Primary key derived from field flag instead of separate callback
[1.2.0] - 2026-03-01
Added
- Changeset validators:
validate_exclusion,validate_subset,traverse_errors,prepare_changes,optimistic_lock - Query extensions: subqueries in WHERE, CTEs, UNION/INTERSECT/EXCEPT, window functions (
select_expr), query scopes kura_sandbox- test transaction rollback for isolated concurrent testskura_stream- server-side cursor batching for large result setsinsert_allwith RETURNING support
Changed
to_sql_from/2refactored as keystone for all query compilation
[1.1.0] - 2026-02-27
Added
- Foreign key constraints in migrations -
references,on_delete,on_updatefields on#kura_column{}generate inlineREFERENCES "table"("col") ON DELETE CASCADEetc. kura_changeset:validate_confirmation/2,3- validates a field has a matching<field>_confirmationin params (for password/email confirmation flows)kura_repo_worker:exists/2- checks if any record matches a query, returns{ok, true | false}kura_repo_worker:reload/3- re-fetches a record from the database by its primary key
[1.0.4] - 2026-02-26
Fixed
- ExDoc build failure -
doc/architecture.mdwas wiped by edoc before ex_doc could read it; moved toguides/architecture.md - Removed
docfrom hex include_files (generated output, not source)
Added
- ExDoc build step in CI to catch documentation errors early
[1.0.3] - 2026-02-26
Added
- Rolling deployment safety warnings - detect dangerous migration operations (
drop_column,rename_column,modify_column,drop_table,add_column NOT NULLwithout default) and log warnings before execution - Optional
safe/0callback onkura_migrationbehaviour to suppress warnings when the expand-contract pattern has been followed - Rolling deployments guide (
guides/rolling_deployments.md) documenting the expand-contract pattern with step-by-step examples
[1.0.2] - 2026-02-24
Added
kura_preloadermodule - extracted preload logic fromkura_repo_workerinto a dedicated modulekura_changeset_assocmodule - extractedcast_assoc,put_assoc, and association coercion fromkura_changeset- Comprehensive integration tests (356 total) covering all query operators, aggregates, joins, bulk ops, multi pipelines, on_conflict upserts, constraint errors, type round-trips, and all association/preload types
Fixed
- Constraint error handling (
unique_constraint,foreign_key_constraint,check_constraint) now correctly unwraps pgo{pgsql_error, Map}tuples put_assocfor many_to_many now preserves primary key in changeset data
[1.0.1] - 2026-02-22
Added
- Embedded schemas guide (
guides/embedded-schemas.md) - Architecture doc linked in hexdocs extras
- Logo displayed in hexdocs
- Navigation groups: Getting Started, Guides, Reference
Changed
- Hidden internal modules (
kura_app,kura_sup) from docs
[1.0.0] - 2026-02-22
Changed
- Consolidated CI and release into a single GitHub Actions workflow
- Updated README features list to reflect all capabilities added since 0.2.0
- Fixed stale
log_queriesconfig reference in README (nowlog) - Fixed stale migration discovery docs in README (module-based since 0.3.0)
[0.5.0] - 2026-02-14
Added
- Embedded schemas (
embeds_one,embeds_many) stored as JSONB withcast_embed/2,3 - Many-to-many associations with
join_through/join_keys, preloading, and persistence viacast_assoc/put_assoc - Schemaless changesets -
cast/4accepts a types map for validation-only workflows Makefilefor local test lifecycle management (make testwith Docker Compose)- Schemaless changesets guide (
guides/schemaless-changesets.md)
[0.4.1] - 2026-02-14
Added
- Hex documentation guides for enums, telemetry, and cast_assoc
[0.4.0] - 2026-02-14
Added
- Enum type (
{enum, [atom()]}) - stored asVARCHAR(255), cast/dump/load between atoms and binaries Query telemetry via
sys.config-{kura, [{log, true | {M,F}}]}with timing on every querykura_changeset:cast_assoc/2,3- nested changeset casting forhas_manyandhas_oneassociationskura_changeset:put_assoc/3- directly attach maps or pre-built changesets as association changesassoc_changesfield on#kura_changeset{}record- Nested insert/update - automatic transaction wrapping with FK propagation when
assoc_changespresent kura_repo_worker:build_log_event/5anddefault_logger/0exported for testability- Architecture documentation (
guides/architecture.md) - Feature guides: enums, telemetry, cast_assoc (
guides/)
Changed
- Telemetry reads from
application:get_env(kura, log)instead of repoconfig/0map - Removed
log_queriesapplication env default (replaced bylog) kura_repo_worker:insert/2andupdate/2refactored to support nested association persistence
Removed
maybe_log/2internal function (replaced by centralizedemit_log/5)
[0.3.0] - 2026-02-14
Added
- Module-based migration discovery (no filesystem scanning)
- Xref checks in CI
- rebar3_kura plugin reference in README
Removed
migration_pathsconfiguration (migrations now discovered automatically from compiled modules)
[0.2.0] - 2025-02-14
Added
- Constraint declarations (
unique_constraint,foreign_key_constraint,check_constraint) with automatic PostgreSQL error mapping kura_multifor atomic transaction pipelines with insert/update/delete/run steps- Association support (
belongs_to,has_one,has_many) with preloading - Nested preloads
- Standalone preloading via
kura_repo_worker:preload/4 - Query preloads via
kura_query:preload/2 - Upsert support (
insert/3withon_conflictoption) - Bulk operations:
insert_all/3,update_all/3,delete_all/2 kura_changeset:validate_change/3for custom validation functionskura_changeset:apply_action/2- Module documentation (
-moduledoc/-doc) for all public modules - Usage guides: Getting Started, Changesets, Query Builder, Associations, Multi, Migrations
- CI/CD with GitHub Actions
- CHANGELOG
[0.1.0] - 2025-01-15
Added
kura_schemabehaviour for defining database-backed schemaskura_changesetfor casting, validation, and change trackingkura_querycomposable query builderkura_query_compilerfor parameterized SQL generationkura_repobehaviour andkura_repo_workerfor CRUD operationskura_typestype system (id, integer, float, string, text, boolean, date, utc_datetime, uuid, jsonb, arrays)kura_migrationbehaviour andkura_migratorfor DDL migrations- Automatic timestamps (
inserted_at,updated_at) - Query logging via application env