Skip to content

v0.12.0

Choose a tag to compare

@github-actions github-actions released this 02 Oct 18:18
· 2212 commits to master since this release
a38061f

Ptah v0.12.0 adds conditional PostgreSQL role declarations to desired SQL and fixes migration formatting that could change function bodies and multiline SQL literals.

Declare PostgreSQL roles in conditional SQL

Desired schemas can now include supported role-bootstrap blocks:

DO $bootstrap$
BEGIN
  IF NOT EXISTS (
    SELECT 1 FROM pg_catalog.pg_roles WHERE rolname = 'app_reader'
  ) THEN
    CREATE ROLE app_reader NOLOGIN;
  END IF;
END;
$bootstrap$;

CREATE TABLE documents (id bigint PRIMARY KEY, body text NOT NULL);
GRANT SELECT ON TABLE documents TO app_reader;

Native Ptah and Ptah Compat read these declarations into the role model without executing the procedural body. Generated migrations create roles before dependent grants. Ordered SQL sources share the declared role state.

This is a bounded interpretation, not a general PL/pgSQL interpreter. Unsupported statements and conditions are refused, including in branches that would not run. Replaying migration history remains separate and requires a disposable server for procedural or role effects. See conditional role bootstrap and #3997.

Preserve quoted SQL during formatting

The compatibility sql template formatter now adds indentation only outside quoted SQL. Function bodies, multiline string values, and quoted identifiers keep their contents. Previously, formatting a generated PostgreSQL function could change its body and produce another migration on the next diff.

The fix was tested with Scooter's notification function and triggers: changing the function body and trigger condition produces a migration that replays successfully, and the next diff is empty (#4007).

Dependency updates

This release also updates the pgvector test image to 0.8.7, OpenTelemetry to 1.47.0, OpenTelemetry Contrib to 0.72.0, and other runtime and documentation dependencies.

Upgrade

Install v0.12.0 through the installation guide, or use ghcr.io/stokaro/ptah:0.12.0 / stokaro/ptah:0.12.0. Both images include ptah, ptah-compat, and ptah-ls with the MIT license.

Full changelog