Skip to content

NTNT v0.6.2 — Database setup, PostgreSQL TLS and migration time limits

Choose a tag to compare

@github-actions github-actions released this 18 Nov 03:18
· 42 commits to main since this release
6cd3861

NTNT v0.6.2 — Database setup, PostgreSQL TLS and migration time limits

NTNT 0.6.2 makes ntnt db easier to set up and able to manage remote PostgreSQL.
ntnt db init and ntnt db new scaffold a database's configuration and migration
files, examples/database-dev provides tested local setups, ntnt db connects to
PostgreSQL over verified TLS, and PostgreSQL databases can raise the migration time
limits for large tables. It also fixes a macOS std/process failure for commands
that exit immediately.

This announcement describes the changes since the last published release,
v0.6.1. The database workflow itself (status, plan, migrate, verify,
reconcile), native SSE and WebSockets were already available there; 0.6.2 adds no
realtime features.

Database scaffolding

ntnt db init --engine sqlite (or --engine postgresql) writes a commented
[databases.app] section to ntnt.toml with a development target, a disposable
scratch database and an approval secret, declares those secret names (never their
values) and creates migrations/. --database <name> replaces app. If
ntnt.toml exists, the section is appended and the existing bytes are kept; init
refuses, changing nothing, when that database or one of its secrets is already
declared. ntnt db new <name> creates the next numbered migration file, such as
migrations/0002_<name>.sql, without reading secrets or connecting to a database.
Neither command overwrites a file (#348). The manifest can still be written by
hand; see Quick start.

A tested local development setup for ntnt db

examples/database-dev provides what local ntnt db work needs (#345): a target
database, a separate disposable scratch database and an approval step.

  • PostgreSQL: one docker compose up -d --wait starts PostgreSQL 17 on
    127.0.0.1:55432. An init script creates the target and scratch databases, each
    owned by its own unprivileged role, with matching settings. A dev.env sets the
    development secrets. The data lives in a named volume: docker compose down
    keeps it, and down -v resets it.
  • SQLite: . ./dev.env creates the empty target and scratch files once and sets
    their absolute paths.
  • Approval stays explicit. Development supplies the plan digest through the
    environment provider, and production still requires its separately protected
    provider. ntnt db itself still never provisions databases.

tests/db_dev_recipe.rs runs both setups as documented, including the next
migration and a rejected approval for the wrong plan.

ntnt db connects to PostgreSQL over TLS

ntnt db can now manage remote and managed PostgreSQL. The connection secret's
sslmode accepts libpq's verify-full, verify-ca and require, with sslrootcert
for a private CA (#344). verify-ca, which skips the host-name check, requires an
sslrootcert CA file and never trusts the host CA store.

  • Verified by default. verify-full checks the certificate chain and the host
    name against the host CA store, the store NTNT's other TLS clients use, or only
    against the CAs in sslrootcert.
  • No plaintext fallback. A missing sslmode and prefer/allow are rejected.
    Every TLS mode fails with DB_TLS when the server does not offer TLS. Certificate
    and host-name failures stop before any SQL runs.
  • Plans bind the transport. Each session reports its sslmode, trust source
    and negotiated TLS version, plus what PostgreSQL reports for its own end
    (server_ssl, which is false behind a TLS-terminating proxy or pooler). A plan
    reviewed over verify-full is stale over require or disable. require
    (encrypted, unverified) must be chosen explicitly and is reported as unverified.
  • Upgrade: the target identity now includes the transport, so migrate needs a
    plan made by 0.6.2: regenerate plans made by 0.6.1. sslmode=disable secrets keep
    working unchanged. If a 0.6.1 migrate stopped during CREATE INDEX CONCURRENTLY,
    plan fails with DB_ATTEMPT_UNRESOLVED until that attempt is resolved:
    ntnt db reconcile --plan <the 0.6.1 plan> accepts the 0.6.1 plan over
    sslmode=disable, the only transport 0.6.1 used. Then plan, approve and migrate
    as usual.

Database migration time limits

PostgreSQL databases can raise ntnt db's fixed limits for large tables with an
optional [databases.<name>.limits] table. statement_seconds (default 90, 2
to 86400) bounds each migration script and concurrent index build on the target;
migrator_wait_seconds (default 5, 1 to 300) bounds the wait for a competing
migrator. migrate and reconcile extend their deadlines to fit, plans record
the limits in execution.limits, and changing them requires a new plan.
Manifests without the table keep the old limits and their saved plans stay
valid. A competing migrator now fails with DB_LOCK_CONFLICT instead of a
statement timeout. See
Time limits (#346).

Fixes

  • macOS std/process: starting a command that exits immediately could fail
    with failed to configure process monitoring: No such process (os error 3). The
    child had exited before NTNT began watching it; it is now treated as exited and
    its result is returned as usual (#381).

Tests and CI

  • Seven timing-dependent tests that could fail without a bug were removed (#383).
    Making the rest of the suite deterministic is tracked in #382.
  • SSE over HTTP/2 (h2c) and callback saturation during worker loss now have real
    protocol tests (#372).
  • The CI status check fails unless every job succeeded or was skipped, so a job
    that never ran can no longer pass it (#379).

Compatibility and upgrade checklist

  1. Regenerate ntnt db plans with 0.6.2. A plan's target identity now includes
    the PostgreSQL transport, so migrate rejects plans made by 0.6.1. Plan, review
    and approve again with the new binary; applied migration history is unchanged.
  2. Existing PostgreSQL secrets keep working. 0.6.1 required sslmode=disable,
    and those secrets connect as before. To use TLS, set sslmode=verify-full (with
    sslrootcert for a private CA). require must be chosen explicitly and is
    reported as unverified.
  3. Resolve interrupted index builds first. If a 0.6.1 migrate stopped during
    CREATE INDEX CONCURRENTLY, run ntnt db reconcile --plan <the 0.6.1 plan>
    before planning with 0.6.2.
  4. A competing migrator now fails with DB_LOCK_CONFLICT instead of a statement
    timeout. Update scripts that matched the old error.
  5. Large migrations: if a script or concurrent index build needs more than 90
    seconds, set statement_seconds under [databases.<name>.limits] and make a new
    plan.

Linux x64, Linux ARMv7 hard-float, macOS Apple Silicon and Windows x64 archives
retain their normal checksum and packaging gates, and the binary's dependency
versions are unchanged from 0.6.1. Contributors and builders use the pinned Rust
1.99.1 toolchain. This release does not add schema-aware query validation (#347),
coordinated multi-worker development reload (#361) or realtime isolation between
applications in one process (#389).

The version-pinned references below become available with the v0.6.2 tag:

Full changelog: v0.6.1...v0.6.2

What's Changed

Full Changelog: v0.6.1...v0.6.2