# Kura 2.x - pluggable backends, minato, encryption at rest and pgvector

**URL:** <https://erlangforums.com/t/kura-2-x-pluggable-backends-minato-encryption-at-rest-and-pgvector/6156>\
**Category:** Libraries\
**Tags:** erlang\
**Created:** [November 21, 2026, 5:55pm UTC](https://erlangforums.com/t/kura-2-x-pluggable-backends-minato-encryption-at-rest-and-pgvector/6156 "2026-11-21T17:55:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taure](https://erlangforums.com/user_avatar/erlangforums.com/taure/32/846_2.png) [@Taure](https://erlangforums.com/u/Taure)\
**Post date:** [November 21, 2026, 5:55pm UTC](https://erlangforums.com/t/kura-2-x-pluggable-backends-minato-encryption-at-rest-and-pgvector/6156/1 "2026-11-21T17:55:20Z")

</div>

Kura is a database layer for Erlang, Ecto-style schemas, changesets, composable queries and migrations in plain Erlang. I posted about 1.x in [Kura - Ecto-inspired database layer for Erlang](https://erlangforums.com/t/kura-ecto-inspired-database-layer-for-erlang/5453). A lot has changed since then so here is a new thread for 2.x. Current version is 2.31.

## Core and backends

In 2.0 kura is split into a core and backends. Core has schemas, changesets, the query builder and the migrator. The backend brings the dialect, driver and pool. Two backends exist today, kura\_postgres and kura\_sqlite.

```erlang
{deps, [kura, kura_postgres]}.

```

```erlang
[{kura, [
    {repos, #{
        my_repo => #{
            backend => kura_backend_postgres,
            host => "localhost",
            database => "my_app_dev",
            user => "postgres",
            password => "postgres",
            pool_size => 10
        }
    }}
]}].

```

Config is a map of repos, so one app can run several repos, each with its own backend. Kura starts the pools at boot. A backend declares what it supports (window functions, full-text search, row locks, vectors and so on) and kura checks a query against that before it is sent, so you get an error from kura and not a syntax error from the database.

kura\_postgres doesn’t use pgo anymore. It runs on minato, a Postgres client I wrote for this. It’s on Hex at 1.2 and works on its own if you just want a client without kura.

## Encryption at rest

Wrap a field type in `{encrypted, Type}` and the value is stored AES-256-GCM encrypted in a BYTEA column. Casting and validation still run on the plaintext.

```erlang
fields() ->
    [
        #kura_field{name = id, type = id, primary_key = true},
        #kura_field{name = ssn, type = {encrypted, string}, nullable = false}
    ].

```

Keys can be rotated, and there is a deterministic mode so equality lookups on an encrypted column still work. Only ciphertext goes into the query, the query cache, telemetry and logs.

## pgvector

`{vector, N}` fields, and `kura_query:distance/3` for nearest neighbour search:

```erlang
D = kura_query:distance(embedding, cosine, QueryVector),
Q = kura_query:from(memory),
Q1 = kura_query:select_expr(Q, [{id, id}, {content, content}, {dist, D}]),
Q2 = kura_query:order_by(Q1, [{dist, asc}]),
Q3 = kura_query:limit(Q2, 10),
{ok, Rows} = kura_repo_worker:all(my_repo, Q3).

```

Distance also works in where and having, and `create_index` takes using, opclass and with, so HNSW and IVFFlat indexes come from a normal migration.

## Other things since 1.x

Composite primary keys and composite foreign keys, all the way through associations, preload and casting. Window functions via `over/2`, full-text search with a `matches` operator, exclusion constraints, read-only repos with replica routing, UUIDv7 primary keys if you want them.

The migrator got `fake/1` to baseline an existing database without running the DDL, migrations outside a transaction so CREATE INDEX CONCURRENTLY works, and discovery across several applications.

## Hardening

The last couple of months went mostly to this. Every identifier is quoted. Attribute tenancy applies to every query, write and preload, and `require_tenant` makes a query without a tenant raise instead of reading across tenants. Schemas can list fields in `redact/0` and those stay out of logs and telemetry. `kura_query:lock/2` takes a lock term instead of raw text.

The new checks are off by default in 2.31 and log one warning per boot when they would apply. In 3.0 they become the default. guides/upgrading.md lists every setting and its default, so you can turn them on one at a time before that.

CI gates new code on mutation score too.

## Links

Kura: [GitHub - Taure/kura: Ecto-style database layer for Erlang: schemas, changesets, composable queries, migrations and multi-tenancy. PostgreSQL and SQLite backends. · GitHub](https://github.com/Taure/kura)  
HexDocs: [kura v2.31.2 — Documentation](https://hexdocs.pm/kura)  
kura\_postgres: [GitHub - Taure/kura\_postgres: PostgreSQL backend for kura, the Ecto-style Erlang database layer. Runs on the minato client. · GitHub](https://github.com/Taure/kura_postgres)  
kura\_sqlite: [GitHub - Taure/kura\_sqlite: SQLite backend for kura, the Ecto-style Erlang database layer. Runs on the esqlite NIF driver. · GitHub](https://github.com/Taure/kura_sqlite)  
minato: [GitHub - Taure/minato: An independent Erlang Postgres client. Bulk-framed wire protocol, caller-owned sockets, pure codecs. · GitHub](https://github.com/Taure/minato)  
opentelemetry\_kura: [GitHub - Taure/opentelemetry\_kura: OpenTelemetry tracing for kura, the Erlang database layer: a span for every query. · GitHub](https://github.com/Taure/opentelemetry_kura)  
rebar3\_kura (migrations generated from schema changes): [GitHub - Taure/rebar3\_kura: rebar3 plugin for kura: generates Erlang database migrations from schema changes and scaffolds new projects. · GitHub](https://github.com/Taure/rebar3_kura)
