Changelog

View Source

All 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 the from table (see Changed).
  • The exported type kura_repo_worker:hook_error/0, a hook's {error, Reason} in the specs of insert/2,3 and update/2.
  • kura_query:from/1 and join/4,5 specs accept a binary table or CTE name.
  • Optional kura_dialect callback convert_values/1: a dialect converts a query's bound values before it is compiled. kura_dialect_pg implements it (see Changed).
  • kura_changeset:delete_change/2 removes 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, default randomized), normalize (none | casefold | nfc | nfc_casefold, deterministic string/text only; nfc_casefold decomposes 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) and legacy (accept | reject, default reject). 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 mode 1): 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, jsonb and arrays are refused. legacy => reject refuses 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 and NULL-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/2 and having/2 turn =, bare equality, in, != and not_in on 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 to IN and NOT IN. A value that does not cast raises {kura, {invalid_lookup_value, Field}}; passing either operator to where/2 raises {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 field where/2 and having/2 read the keyring, so they can raise a keyring error such as {kura_crypto, no_deterministic_key}. The rewrite costs about 30-60 ns per where/2 on a schema without deterministic fields.
  • kura_encryption:lookup_params/3 returns the ciphertexts a lookup binds, for a {fragment, SQL, Params}.
  • kura_keyring gains the optional callbacks deterministic_active/0 and deterministic_key_ids/0, and kura_keyring_env implements both (deterministic_active and deterministic_keys in the encryption config; an id in deterministic_keys that is not in keys raises {kura_crypto, {unknown_key_id, Id}}, anything but a list of key ids {kura_crypto, invalid_deterministic_keys}). Deterministic writes use deterministic_active, never active, and raise {kura_crypto, no_deterministic_key} without one. A lookup is encrypted under deterministic_active and every other deterministic_key_ids/0 id, 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 key deterministic_active and keeping the old id in deterministic_keys until no stored value uses it; != and not_in are correct only while every stored generation is a lookup key.
  • kura_crypto:encrypt/3 and decrypt/3; kura_types:validate_encryption/1 and deterministic_inner/1; the types kura_crypto:mode/0, legacy/0 and policy/0, kura_types:encryption_opts/0 and normalize/0, and kura_schema:field_encryption/0.
  • A pgvector distance threshold in where/2 and having/2: {kura_query:distance(Field, Metric, Vector), Op, Number} with Op one 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 in order_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 of in, exists and not_exists conditions; 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 from where/2 and having/2.
  • Map-form create_index takes using (access method, such as hnsw, ivfflat, gin), opclass (operator class, one column only) and with (storage parameters, atom keys to integers), for pgvector HNSW and IVFFlat indexes among others. using, opclass and the with keys must match ^[a-z][a-z0-9_]*$ and are emitted quoted. A bad identifier, a non-integer with value, an empty with map, opclass on several columns or a name that is not a binary of 1 to 63 bytes raises {invalid_index_option, Option, Value}. A migration run checks every map-form create_index before it applies anything, and fails with {invalid_index_option, Version, Option, Value}. On a repo whose dialect is not PostgreSQL, using, opclass and with raise {invalid_index_option, Option, {unsupported_dialect, Dialect}}.
  • kura_migration:index_name/3 resolves the name of an index from its options: the declared name, or index_name/2.
  • kura_schema_verify compares the access method (pg_am.amname) of a declared index that names one with using, so a btree no longer satisfies a declared hnsw index. Without using any method counts.

Changed

  • count/2, aggregate/3,4 and kura_stream:stream/3,4 leave out soft-deleted rows, as all/2, update_all/3 and delete_all/2 already did; mark the query with kura_query:with_deleted/1 to keep them. all/2 on a query from a CTE name or a bare table atom no longer crashes.

  • insert/3 (an insert with options such as on_conflict) runs prepare_changes/2, before_insert/1, after_insert/1 and the changeset's associations, like insert/2. after_insert/1 runs whenever the statement returns a row, including when an upsert updated one. A changeset with associations refuses any on_conflict action but nothing (with or without a guard), raising {kura, on_conflict_with_assocs}.

  • On PostgreSQL, a where value compared to a field of the from schema 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 on id, integer, bigint, smallint, float, boolean, date and time fields, and on datetimes without an offset other than Z or a fraction. An integer binary over 20 bytes or a float binary over 64 is not parsed. Every other value, decimal included, is bound as given. The conversion is the new optional kura_dialect callback convert_values/1, implemented by kura_dialect_pg; kura_query:where/2 stores 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 own from schema.

  • kura_repo_worker:update_all/3 and delete_all/2 raise {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 the from table, the where conditions and the prefix, so these clauses used to be dropped silently: delete_all on a joined query deleted every row its where matched in the from table, 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 so kura_changeset:cast/4) refuses an out-of-range date or time: an hour over 23 (but 24: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 from schema with the from table 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 and order_by names that are select_expr/2 aliases stay bare. Which fields are qualified is decided by the new kura_dialect:qualified_columns/1. kura_sqlite delegates to this dialect and inherits the qualification; a where on a byte field of the from schema under a join needs the kura_sqlite release that uses kura_dialect:qualified_columns/1. A deterministic lookup on a field of the from schema is offered only by the from schema, so a plain from field 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/3 measures a binary in characters (Unicode code points, the unit of VARCHAR(N)) rather than bytes, so a multibyte string counts fewer units than before. A value that is not valid UTF-8 gets the error is not valid UTF-8. On a field typed binary or {encrypted, binary} it still counts bytes, and the messages say byte(s).

  • cast/4 looks up table/0 only when the schema declares constraints or indexes, so an embedded schema module needs only fields/0.

  • kura_types:encryption/1 returns the full spec, with mode, legacy and normalize, and kura_schema:encryption_specs/1 returns it with context resolved, in place of #{context => Ctx} alone.

  • kura_crypto:decrypt/2 (the {encrypted, Inner} read path) reads a deterministic v2 frame of its column, as legacy => accept does; a frame with its mode byte changed from 0 to 1 now raises bad_tag rather 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_index honours name. It used to be ignored, the index always taking kura_migration:index_name/2. A migration that passed name now creates the index under that name, and a unique index declared in indexes/0 with a name maps 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. Without name, naming is unchanged.

    Breaking: a name that 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 in indexes/0 it raises from kura_changeset:cast/4 on every write to that schema. In a migration's create_index it aborts the run, including an applied migration replayed on a fresh database. Write name => ~"users_email_index", not an atom.

  • {Field, is_nil} and {Field, is_not_nil} on an encrypted field are accepted by where/2. They bind nothing, and NULL is stored unencrypted.

  • order_by/2 on an encrypted field raises {kura, {encrypted_field_in_order_by, Field}}; sum, avg, min or max of one, in select/2, the aggregate helpers or a window function, raises {kura, {encrypted_field_in_aggregate, Field}}; and a window partition_by or order_by on one raises {kura, {encrypted_field_in_window, Field}}. The result would be ordered or computed over ciphertexts. count is allowed. The compiler re-check covers these too.

  • group_by/2, distinct/2 (DISTINCT ON) and a join on column 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 a select_expr/2 alias of an encrypted field raise too. A select_expr/2 distance 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 as not_a_column, so its values stay out of the reason.

  • kura_schema refuses 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 encrypted in any form other than {encrypted, Inner} is treated as encrypted and refused: schema load raises {kura, {unsupported_encrypted_type, Mod, Field}}, and cast/2, dump/2, load/2 and to_pg_type/1 raise {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 whose Inner cannot 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/2 on an encrypted type loads undefined, which kura_sqlite returns for NULL, as undefined, and raises {kura_crypto, malformed_frame} for any other non-binary value. Both crashed with a function_clause in format_type/1 before.

  • 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 window partition_by or order_by, or sum, avg, min or max on an encrypted field or a select_expr/2 alias of one: sort, group or compute on the loaded rows instead.
    • A join on column, a primary key, or an association key that is encrypted, including the owner-side target_key of a has_many or has_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/2 and 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,5 or with_cte/3 that 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, an in-list element or a between bound: use exists, not_exists or a single-column in.
    • {encrypted, Inner} with an Inner that cannot be encrypted, or any other type tagged encrypted: the schema fails to load and to_pg_type/1 raises {kura_crypto, unsupported_encrypted_type}, so no migration column is generated for it. {array, {encrypted, Inner}} keeps its BYTEA[] column and data unchanged.
  • Application boot starts a repo's pool the way kura_repo_worker:start/1 does, through kura_db:start_pool/1, from the config kura_repo:config/1 returns (#197). Boot now applies the repo's init/1, loading the repo module first, and names the pool from the pool key. A repo configured with pool => X got a pool named after the repo at boot while its queries went to X, and connection settings set in init/1 were missing from the pool boot started. Boot still logs a pool that did not start and carries on; start/1 returns the error.

  • The legacy flat single-repo form ({repo, _} with connection keys at the kura env level) takes its host, port, password and pool_size defaults from the pool module instead of from kura at boot (#197). Boot filled in host "localhost", port 5432, an empty password and pool_size 10 that start/1 did not, so the same config could start at boot and fail through start/1. Both now hand the pool module the settings as configured, as start/1 has done since #193, and kura_postgres applies the same host, port and pool_size defaults. The user and database defaults stay for now; see Deprecated. The flat form also no longer passes a repos map in the kura env to the pool along with the connection settings. Requires the kura_postgres release containing kura_postgres#31.

  • A repo init/1 that 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 as redacted, since init/1 is the consumer's code and its reason may hold a secret it fetched. kura_repo_worker:start/1 returns {error, {init_failed, {Class, Shape}}}. For a repo in the repos map or the flat form, init/1 runs during kura's own start, before the consuming application, so it must not call that application's processes.

  • A repo's init/1 no 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 a persistent_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. An init/1 that 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/1 on 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 failing init/1, keeps the previous settings. A repo whose pool kura did not start falls back to the old lookup, its config read and init/1 run on each call. kura_repo:config/1 still 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_module or driver_module with application:set_env no longer takes effect on the next query: queries keep the settings stored at pool start until kura_repo_worker:start/1 is called again. A repo whose pool kura did not start still sees the change on its next call.

  • Upgrading: read_only is captured when the repo's pool starts (#200). A started repo switched to read_only => true at runtime, with application:set_env or by init/1 reading a flag, keeps accepting writes until kura_repo_worker:start/1 is called again for it. Call start/1 after changing it.

  • Upgrading: replicas, uuid_version, dialect, pool, pool_module and driver_module are captured the same way (#200). A test or a release task that changes them with application:set_env on a started repo must call kura_repo_worker:start/1 for 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/1 returns {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, as kura_pool_minato did. The repo that started a pool can start it again and gets ok. 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 takes kura_db:stop_pool/1 and then kura_repo_worker:start/1; start/1 alone returns ok and leaves the pool as it is. A pool stays owned by the repo that started it until kura_db:stop_pool/1 releases 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/1 raises {pool_owned_by, Owner}, which covers a repo kura never started and one stopped with kura_db:stop_pool/1 whose 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 returns ok, the failure is logged with only the shape of its reason, and that pool stays owned. kura_db:stop_pool/1 stops 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_assoc DELETE 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 $N placeholders 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 through kura_db:query/3 rather than kura_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 of insert, update, delete and insert_all, and the from of the join-table query handed to to_sql/1 and delete_all/1 (#153). A join_through given as a binary reaches the dialect that way. kura_query:from/1 and the repo's query functions still take a schema module or an atom. kura_dialect_pg returns 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 every migration_lock_retry_interval milliseconds (default 100), instead of blocking in pg_advisory_xact_lock (#139). A node waiting inside a statement, or inside one long transaction, is a transaction that CREATE INDEX CONCURRENTLY on the lock holder waits for, and the two deadlocked.

    Upgrading: deploy this kura on every node before shipping the first transactional() -> false migration. 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 ignores transactional/0 and concurrently, so if it runs the migration itself it builds the index with a plain CREATE INDEX that blocks writes to the table.

  • A schema_migrations read that fails stops migrate/1, rollback/1,2,3 and fake/1,2,3 with {error, {schema_migrations_unreadable, Reason}}, where it was taken as an empty table (#139). A non-transactional migration's re-read failing, on a lock_timeout for instance, would otherwise run an applied migration again in autocommit. status/1 still reports such a table as nothing applied.

  • The migrator keeps only a Postgres error's code, message, severity, hint, schema, table, column, data_type and constraint in what it logs, returns and emits as telemetry error_reason (#139). A failed CREATE UNIQUE INDEX put the duplicated key values, often personal data, in detail.

  • The [kura, migrator, migrate, stop] event carries the new applied_versions metadata, and on an error its applied_count and applied_versions give the migrations a split run committed before it failed, which stay applied, where applied_count was 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_timeout app env (milliseconds, default infinity) ends it with {error, migration_lock_timeout} from migrate/1, rollback/1,2,3, fake/1,2,3 and ensure_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_interval below 10 ms is taken as 10, where 0 busy-looped.

  • Inside kura_db:transaction/2 or 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/1 returns {error, Reason} when the pool does not start, where it logged the failure and returned ok (#192). A test setup written as ok = kura_repo_worker:start(my_repo) now stops at the failure. Secrets in Reason are replaced by redacted. Application boot still logs a pool that did not start and carries on.

  • kura_repo_worker:start/1 hands the connection settings in the repo's config to its pool_module, the way application boot does, instead of building a Postgres-shaped config with defaults for host, port and user (#193). A kura_sqlite repo started this way gets its own defaults, :memory: among them, where it raised {missing_repo_config, database}. A Postgres repo in the repos map or the per-app form that left out username and relied on the postgres default must now set it. With kura_postgres from this release on, the pool refuses to start with {missing_option, user} and start/1 returns the error. A missing database no longer raises missing_repo_config: minato connects to the database named after the user, as libpq does. The flat form on Postgres keeps its user and database defaults 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; see kura_dialect.

  • {Field, '=', Value} always binds Value. It used to be dispatched as {Field, Value}, so {status, '=', is_nil} compiled to IS NULL.

  • A row-value in whose 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_in and row-value in placeholders is linear in the list length; it was quadratic.

Security

  • kura_keyring_env raises {kura_crypto, invalid_keyring_config} when the encryption config is not a map or its keys is not a proper list. It used to raise a badmap or badarg whose 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/2 only refused an encrypted field when it was the first element of the condition, and having/2 did not check at all. {'not', {ssn, V}}, {[ssn], in, [{V}]}, {[id, ssn], in, [{1, V}]} and having(Q, {ssn, V}) were accepted and sent the plaintext to the server as a bind parameter and into the telemetry and log params; the not form also matched every row. Both functions now walk the whole condition (and, or, not, in, row-value in, between, every comparison operator, in subqueries) 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/1 returned none, 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 a BYTEA[] column.
  • An attribute tenant on an encrypted field was refused on queries but not on update and delete, 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/3 or insert_all/4 with an on_conflict other than nothing) under an attribute tenant on an encrypted field guarded the conflict update with table.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}}. A nothing action 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 in Sub naming an outer encrypted field that Sub'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 but exists, not_exists or a single-column in, such as {id, '=', {subquery, Q}}, an in-list element or a between bound, 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 from or join naming a CTE over an encrypted schema had no encrypted fields in scope, so where(from(enc_cte), {ssn, V}) bound the plaintext, as did a condition added before with_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 a SELECT * hides the positions), and with_cte/3 and join/4,5 re-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_many or has_one whose #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, or or a row-value in crashed the filter guard with a function_clause whose arguments carried the plaintext, and an and or or over 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 after where/2 (for example a new from), compiled with the plaintext bound. kura_query_compiler's to_sql/2, to_sql_cached/2, to_sql_from/3, update_all/3 and delete_all/2 now run kura_query:check_encrypted/1 over the whole query (wheres, havings, subqueries, CTE bodies, union branches) before compiling. to_sql_cached/2 runs 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 through to_sql/2 and is never cached. A hit costs what it did before the guard (cached get-by-id in kura_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 encryption keyring 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 an encryption or keyring key, in a map or a key-value list, now has its value replaced by redacted, like password. 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 or in/exists subquery 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/2 and delete/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_all and insert/3 did 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_to whose 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/1 stored 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 of is_nil or is_not_nil is refused too: the condition read it as a null test, so is_not_nil matched 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/2 and 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 fix kura_dialect_pg, kura_preloader and kura_repo_worker already 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, and kura_migrator's fallback.
  • kura_query:where/2 raises 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, into pg_stat_statements and the query log.

Fixed

  • kura_types:cast/2 on an empty time (~"", ~"2024-01-01T") raised badarg; it now returns a cast error, so a changeset gets a field error.

  • A utc_datetime with an offset other than Z dropped the offset, so ~"2024-01-01T10:00:00+02:00" was stored as 10:00 UTC. The offset (+HH:MM, +HHMM or +HH) is now applied, giving 08:00 UTC; a malformed one is a cast error. A naive_datetime and a time keep 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:00 and a leap second (:60) become the next day or minute, the value a read returns. A time keeps {24, 0, 0}.

  • In a sandboxed test, a COMMIT, END or ROLLBACK run 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). A kura_db:transaction/2 whose function caught that error raises it too, rather than transaction_rolled_back. kura_driver:query_on/4 takes a transaction option (starts or inside) for this; a driver that ignores it behaves as before. The driver contract now names transaction_ended_by_statement as 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/1 nor ets:info(Tab, memory) sees them, so an entry holding a large binary counted as a few words.

  • kura_types:cast/2, dump/2 and load/2 crashed with function_clause instead 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,4 honour on_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. The DO UPDATE SET list is built from EXCLUDED, because one clause applies to every row.

  • kura_schema_verify matches a declared index by what it is instead of by the generated <table>_<cols>_index name: 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 as ADD CONSTRAINT ... UNIQUE no longer reports as missing_index. A partial index's predicate is not compared, since PostgreSQL stores its own rewrite of the WHERE text.

    Upgrading: verify/1,2 can 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, without UNIQUE, partial where the declaration is not, or left invalid by a failed CREATE INDEX CONCURRENTLY, which PostgreSQL ignores, for ON CONFLICT too.

Deprecated

  • The user and database defaults of the legacy flat single-repo form on Postgres (#197). When the kura env sets {repo, Repo}, has no repos map and the dialect is kura_dialect_pg, a user (when no username is set either) or database the config leaves out is still set to "postgres" when the pool starts, at boot and through kura_repo_worker:start/1 alike, and a warning names the keys filled. Kura 3.0 removes the fill, so set both keys. A repo in the repos map or the per-app form gets no fill: kura_postgres needs its user, and without database it connects to the database named after the user, as libpq does.
  • kura_app:pool_config/0 and kura_app:pool_config/1. Use kura_repo:config/1. They now return the repo's whole config as its pool is started, dialect and pool_module included, with the flat form's deprecated user and database fill and no other defaults (#197). Both now apply the repo's init/1, and raise {init_failed, {Class, Shape}} when it raises, with only the shape of the reason kept. pool_config/1 of a repo configured nowhere returns #{}, where it returned the flat kura env, with Postgres defaults on that dialect, and pool_config/0 returns #{} when the kura env has no repo.
  • kura_preloader:quote_table_bin/1. The dialect quotes and qualifies join tables now (#153).
  • kura_schema_verify:declared_index_name/2. Call kura_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>>, Mode 0 (randomized). Each value is encrypted under a per-column subkey, HKDF-SHA256 of the root key with the context {Table, Column} (the schema's unprefixed table() 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 from field, a join without a select reads the joined value under that field: a v2 value raises, a v1 value decrypts and is returned as the from field.
  • 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/2 on a schema without encrypted fields went from 1.45-1.49 us to 1.53-1.63 us per row.
  • kura_types:dump/3 and load/3 take the column context {Table, Column}, and kura_schema:encryption_specs/1 returns #{Field => #{context => {Table, Column}}} for each stored encrypted field. The insert, update, update_all, insert_all and row-loading seams use them. dump/2 raises {kura_crypto, no_context} for an encrypted value when the write format is v2, and load/2 raises it on a v2 frame, rather than guessing a context. kura_crypto gains encrypt/2, decrypt/2 and write_format/0; an invalid encryption_write_format fails kura application 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 raises no_active_key or {unknown_key_id, KeyId} for v1 as well.
  • kura_schema refuses 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() -> false runs 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. Inside kura_db:transaction/2 or 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, ...} takes concurrently => true (or concurrently in the list form) and emits CREATE 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 standard concurrent_indexes capability (SQLite) it compiles to a plain CREATE 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,5 runs a statement on a connection the caller checked out, with the same telemetry as kura_db:query/3. /5 hands an options map to the driver's query_on/4 (timeout for minato).
  • kura_repo:settings/1 returns a repo's own settings as queries see them, without connection settings or secrets (#200).
  • kura_db:stop_pool/1 stops a repo's pool through its pool module, releases the pool name and drops the repo's stored settings (#201).
  • The kura_pool contract states that start_pool/2 on 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 returns none, unsupported or {ok, #{inner => Inner}}, with array => Depth for 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 the Inner of {encrypted, Inner}; schema validation uses it.
  • kura_hkdf, HKDF-SHA256 (RFC 5869) over crypto: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/3 refuses 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/1 and kura_schema:encrypted_fields/1, both memoised. is_schema/1 replaces three hand-rolled copies of the same code:ensure_loaded/1 + function_exported/3 check, whose negative answer cost a code_server round trip on every call.
  • Version-scoped baselining. kura_migrator:fake(Repo, UpTo) stamps only the pending migrations at or below version UpTo, so a partial brownfield adoption can baseline the introspected prefix and let migrate/1 create the genuinely new tables. fake/3 does the same for one application of a multi-application repo. UpTo must be the version of a discovered migration, so a mistyped timestamp stamps nothing instead of everything (#156).
  • kura_schema:forget/1 drops 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 are l2, cosine and inner_product, emitted as <->, <=> and <#>; a smaller value is nearer for all three. A distance goes in order_by/2, whose spec widens from {atom(), Dir} to {atom() | distance(), Dir}, and in select_expr/2. ORDER BY now carries bind parameters, numbered after HAVING and before LIMIT. The vector is cast and dumped to text when the distance is built, and the query must be from/1 a schema in which the field is a vector or {vector, N} of matching dimension. A distance in where/2, having/2, group_by/2, distinct/2, select/2 (and the aggregate helpers), count/2, a join column or over/2 raises {kura, {distance_not_supported_here, Clause}}, in a condition also as a list element or a between end. 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_search in a transaction) and leaves CREATE EXTENSION to the cluster bootstrap.

Added

  • Multi-application migration discovery. A repo names further applications shipping migrations through the optional kura_repo callback migration_apps/0; the owning application is always included. Applications are ordered by their OTP applications lists, so a dependency's migrations run before its dependents'. No app column and no schema change - existing repos are unaffected.
  • kura_migrator:migration_apps/1 returns the resolved, dependency ordered application list for a repo.
  • kura_migrator:rollback/3 and kura_migrator:fake/2 take 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/2 leaves every other application's migrations pending.

Security

  • update_all/2 wrote 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 by update_all/2 holds plaintext and needs rewriting. A value is ciphertext if and only if kura_crypto:decrypt/1 does 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/3 and the many-to-many join-table name are now quoted, and quote_ident/1 doubles 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 jsonb field is no longer double-encoded. kura_types:dump/2 encoded 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 shaped WHERE 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 the load/2 round trip intact for stored JSON string scalars. This affected insert and update as well, not only the bulk paths.
  • The atom null dumps to SQL NULL for every type, matching undefined. 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 badarg or, 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,3 and update_all/2 return {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 the schema_migrations primary 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/2 no longer skips applied versions that no migration module claims. It used to roll back fewer migrations than asked while reporting success, and ran the surviving down/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/0 never runs before its dependents'. Unchanged for a single-application repo, where the two coincide.
  • schema_migrations is created under the migration advisory lock, in a transaction of its own. CREATE TABLE IF NOT EXISTS is not atomic against a concurrent creator, so two nodes booting together could both pass the existence check and the loser fail on pg_type's unique index.
  • The CREATE TABLE result is no longer discarded. A database that refuses the statement now gives {error, {schema_migrations_failed, Reason}} rather than ok followed by every later query failing on a missing table.

Changed

  • update_all/2 dumps its SET map through the schema's field types whenever the query source is a schema module, matching insert and update. A jsonb map or any other non-primitive is now serialised rather than reaching the driver raw.
  • The bulk write paths accept values in the form cast/2 accepts, not only the form dump/2 accepts. insert_all/2,3 and update_all/2 take 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_conflict accepts {{columns, Cols, #{where => Predicate}}, Action}, emitting ON CONFLICT (cols) WHERE predicate. Tables using partial unique indexes can now express a single-statement upsert; ON CONFLICT ON CONSTRAINT cannot 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 binary where now raises rather than silently emitting no predicate, which would let PostgreSQL infer a different unique index.
  • kura_migrator:status/1 may now return {error, Reason} when discovery fails, and lists migrations in apply order. Unchanged for a single-application repo.
  • kura_migrator:rollback/1,2 and kura_migrator:fake/1 refuse 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, for fake/1, stamps a freshly installed extension's tables as created when they do not exist, after which migrate/1 never creates them. Use rollback/3 and fake/2. A repo without migration_apps/0 is not a multi-application set and is unaffected.
  • kura_migrator:ensure_schema_migrations/1 returns ok | {error, term()} rather than always ok.

[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-populates dialect, pool_module, and driver_module from the aggregator at app start.

    • kura_pool behaviour - connection-pool contract.
    • kura_capabilities behaviour - backend feature flags (e.g. advisory_locks, returning, arrays).
    • kura_dialect behaviour - SQL dialect contract, with optional column_type/1 and format_default/1 callbacks for backend-specific DDL.
    • kura_driver behaviour - 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 primary emits Postgres SQL while analytics emits SQLite SQL. The query cache is keyed per repo so dialects never share entries.

  • kura_app:pool_config/1 returns 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, and dialect/1 take RepoMod as 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_cache keys 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/3 and the rest of the query path route through kura_pool / kura_driver, so backends are swappable.
  • kura_app:pool_config/0 is dialect-aware. PG-shaped defaults (port 5432, user/database "postgres", decode_opts) only apply when dialect is kura_dialect_pg. Other dialects get a pass-through map of user-set kura env keys.
  • kura_app:configure_pg_types/0 only runs when dialect is kura_dialect_pg.
  • kura_repo:read_config/1 returns a pass-through map of all kura env keys (minus bookkeeping). Previously hardcoded the PG-shaped subset and silently dropped pool_module, driver_module, backend.
  • kura_migrator skips pg_advisory_xact_lock when the configured pool doesn't declare the advisory_locks capability. The migration transaction alone serializes runs on backends that lack advisory locks (SQLite, etc.).
  • Single-repo legacy config (flat kura env keys) and the per-app form (application:get_env(OtpApp, RepoMod)) keep working unchanged. The global application:get_env(kura, dialect) is consulted as a fallback when a repo's config map omits dialect.

Removed (BREAKING)

  • kura_pool_pgo, kura_driver_pgo no longer ship in kura. Install kura_postgres for Postgres or kura_sqlite for SQLite. pgo is no longer a runtime dependency of kura. kura_dialect_pg remains in core as the default ANSI-ish SQL emitter that other dialects delegate to.
  • kura_query_compiler:dialect/0 no longer defaults to kura_dialect_pg. Use dialect/1 and configure the dialect per repo (recommended via {backend, ...}), or set the global application:set_env(kura, dialect, Module) for legacy single-dialect setups.
  • kura_db:get_pool_module/1 and get_driver_module/1 error with {no_pool_module_configured, _} / {no_driver_module_configured, _} when not configured. Set {backend, ...} (recommended) or pool_module/driver_module explicitly.

[1.8.0] - 2026-03-06

Changed

  • Breaking: kura_repo behaviour now requires otp_app/0 callback instead of config/0 - database configuration is read from application environment via application:get_env(OtpApp, RepoModule)
  • Optional init/1 callback on kura_repo - modify config at runtime (read secrets from env vars, files, external services)
  • kura_repo:config/1 function reads config from app env, then calls init/1 if defined
  • All internal get_pool/1 calls now use kura_repo:config/1 instead of RepoMod:config()

[1.7.0] - 2026-03-06

Added

  • telemetry library 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/4 and extract_source/1 exported from kura_repo_worker for testing
  • source field 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/0 optional callback on kura_schema for 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/2 helper for generating Ecto-style index names
  • Unique indexes declared via indexes/0 auto-register changeset constraints - no manual unique_constraint/3 calls needed
  • New types: index_def(), index_opts_map() in kura_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/0 optional callback on kura_schema behaviour - declares table-level constraints on the schema
  • Auto-registration of schema constraints on kura_changeset:cast/4 - duplicate inserts get friendly error messages without manual unique_constraint/3 calls

[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/2 returns {ok, V} | error, not map patterns

  • Atom exhaustion risk in enum load/2 - now validates against declared values list instead of binary_to_atom
  • Atom exhaustion risk in kura_repo_worker error handlers - NOT NULL and constraint errors fall back to base atom 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_lock returns 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 tests
  • kura_stream - server-side cursor batching for large result sets
  • insert_all with RETURNING support

Changed

  • to_sql_from/2 refactored as keystone for all query compilation

[1.1.0] - 2026-02-27

Added

  • Foreign key constraints in migrations - references, on_delete, on_update fields on #kura_column{} generate inline REFERENCES "table"("col") ON DELETE CASCADE etc.
  • kura_changeset:validate_confirmation/2,3 - validates a field has a matching <field>_confirmation in 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.md was wiped by edoc before ex_doc could read it; moved to guides/architecture.md
  • Removed doc from 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 NULL without default) and log warnings before execution
  • Optional safe/0 callback on kura_migration behaviour 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_preloader module - extracted preload logic from kura_repo_worker into a dedicated module
  • kura_changeset_assoc module - extracted cast_assoc, put_assoc, and association coercion from kura_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_assoc for 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_queries config reference in README (now log)
  • 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 with cast_embed/2,3
  • Many-to-many associations with join_through / join_keys, preloading, and persistence via cast_assoc / put_assoc
  • Schemaless changesets - cast/4 accepts a types map for validation-only workflows
  • Makefile for local test lifecycle management (make test with 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 as VARCHAR(255), cast/dump/load between atoms and binaries
  • Query telemetry via sys.config - {kura, [{log, true | {M,F}}]} with timing on every query

  • kura_changeset:cast_assoc/2,3 - nested changeset casting for has_many and has_one associations
  • kura_changeset:put_assoc/3 - directly attach maps or pre-built changesets as association changes
  • assoc_changes field on #kura_changeset{} record
  • Nested insert/update - automatic transaction wrapping with FK propagation when assoc_changes present
  • kura_repo_worker:build_log_event/5 and default_logger/0 exported 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 repo config/0 map
  • Removed log_queries application env default (replaced by log)
  • kura_repo_worker:insert/2 and update/2 refactored to support nested association persistence

Removed

  • maybe_log/2 internal function (replaced by centralized emit_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_paths configuration (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_multi for 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/3 with on_conflict option)
  • Bulk operations: insert_all/3, update_all/3, delete_all/2
  • kura_changeset:validate_change/3 for custom validation functions
  • kura_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_schema behaviour for defining database-backed schemas
  • kura_changeset for casting, validation, and change tracking
  • kura_query composable query builder
  • kura_query_compiler for parameterized SQL generation
  • kura_repo behaviour and kura_repo_worker for CRUD operations
  • kura_types type system (id, integer, float, string, text, boolean, date, utc_datetime, uuid, jsonb, arrays)
  • kura_migration behaviour and kura_migrator for DDL migrations
  • Automatic timestamps (inserted_at, updated_at)
  • Query logging via application env