Repository navigation
v0.14.0
Ptah v0.14.0 adds experimental executable providers, embedding generations on YDB, and the failed statement and database error code in the run document. PostgreSQL extensions, user types and row-level security, SQL Server security policies, ClickHouse row policies and YDB object permissions are now planned by their feature owners. Comparison and planning fixes cover every engine.
Test a database provider as a separate executable
The native ptah schema inspect, schema plan and schema apply commands can run against a provider that lives in its own executable, built against the new experimental provider SDK. Ptah starts only a provider you name in a manifest, pinned by path, SHA-256 and identity:
{
"format_version": 2,
"providers": [
{
"executable": "/absolute/path/to/provider",
"sha256": "<artifact-sha256>",
"provider_id": "example.org/fixture",
"engines": [{"id": "fixture", "aliases": []}],
"environment": []
}
]
}ptah providers list --provider-config providers.json --json
ptah providers check --provider-config providers.json --provider-engine fixturePass --provider-config to each schema command, and --provider-engine where the database address does not name the engine. A saved plan binds the provider's identity, protocol revision and negotiated target, and a mismatch refuses the apply before it writes anything. A provider that offers transaction sessions for the engine runs --tx-mode file and --tx-mode all inside them; otherwise those modes are refused before anything is sent. Ptah never retries a write or a commit whose outcome it lost, and an explicit provider selection never falls back to an embedded implementation.
The protocol is experimental and accepts common tables and columns. The executable providers guide covers trust, setup and failure recovery. Official provider extraction and a stable contract are tracked in #4204.
Run embedding generations on YDB
ptah inference and the inference_plan and inference_status tools of ptah mcp now run on YDB through its own vector support, which v0.13.0 left out (#4181). A generation stores its vectors beside run state in row tables, builds a vector_kmeans_tree index, and searches with cosine distance, Euclidean distance or inner product.
On YDB the immutable mode is the supported one: YDB has no triggers for the outbox mode. YDB 25.1 needs EnableVectorIndex for the index, and writing into an indexed generation needs a line that maintains vector indexes on write. Refusals name the capability and the server line.
Read which statement failed
ptah migrations up --json now carries a failure object when a statement was sent and failed. It names the migration, the statement's position, and the code the database returned: SQLSTATE for PostgreSQL and the SQLSTATE and error number for MySQL.
"failure": {
"version": 1785255999,
"version_key": "1785255999",
"statement": 2,
"statements": 3,
"sqlstate": "42P01"
}A run that stopped before sending anything carries no failure, so its absence does not claim a statement ran.
Plan engine-specific objects through their owners
Objects that only one engine has are now read, compared, planned and reversed by an owner for that engine, and every source (Go annotations, YAML, HCL and SQL) hands them to it. What changes for a schema:
-
PostgreSQL extensions install and change before anything that uses them, and a raised extension version generates a migration. An extension moved to another schema has that schema created first.
-
A PostgreSQL domain whose CHECK, default or NOT NULL changed is altered in place with
ALTER DOMAIN, and a composite type's attributes change in place. Range types and default privileges moved to their owners too. -
PostgreSQL row-level security: a declaration that names policies and not the table's switches leaves an existing table's switches as they are and enables them on a new table. Two declarations of one policy are refused, naming both.
-
SQL Server security policies are declared with
rls:policyannotations scoped to SQL Server and read fromsys.security_policies. A form SQL Server cannot build is refused when the schema is parsed. -
ClickHouse row policies are declared in HCL, YAML and SQL, and a materialized view's refresh schedule in YAML and HCL as well. Table settings, TTL, sorting and sampling keys change in place where ClickHouse allows it.
row_policy "tenant_rows" { on = table.orders using = sql("tenant_id = 1") to = "ALL EXCEPT admin" as = "RESTRICTIVE" }
-
YDB grants reach topics, coordination nodes, secrets, external data sources and tables, async replications, transfers, streaming queries and resource pools, with
on_topic,on_coordination_nodeand the otheron_*keys spelled ason_tableis://ptah:schema:grant role="readers" privilege="SELECT ROW" on_topic="shop.order_events" -
Oracle domains and object types moved to their owner, and an applied synonym is read back so it converges.
Keep comparison and planning consistent
- Owner transaction requirements are checked before apply, rehearsal and saved-plan execution. They are judged against the transaction the target actually opens, so YDB and ClickHouse statements that must run outside a transaction run as before.
- Spanner adds a NOT NULL column without a default in two steps, drops tables, views and columns without
CASCADE, and reads composite keys correctly. - Spanner, CockroachDB and YugabyteDB compare an index's definition, not only its name. CockroachDB writes only the role options it accepts, and its scoped cleanup runs each drop on its own.
- MySQL and SQL Server write
SERIALas the engine's auto-increment integer, and a column's auto-increment is compared. MySQL compares key parts whole. - SQLite compares and plans indexes, table options and comments.
- PostgreSQL plans a change between logged and unlogged tables, compares index, schema and role comments, and fills NULL rows with a plain
UPDATE. - PostgreSQL migration replay accepts
CREATE TEMP TABLEon its own session and discards that session afterward, so a history that stages data in temporary tables replays. Another session's temporary tables stay protected. ptah-compat migrate diffapplies the environment'sexcludepatterns andschema.modeto both compared schemas. Every migration still replays in full.- ClickHouse compares a skipping index's key expression.
- Go export keeps column comments, index kinds and operator classes, primary-key
INCLUDEcolumns, and the types Oracle and CockroachDB store, so an exported schema plans no change.
Upgrade
Install v0.14.0 through the installation guide, or use ghcr.io/stokaro/ptah:0.14.0 / stokaro/ptah:0.14.0. The archives and images include ptah, ptah-compat, and ptah-ls.
Review a fresh plan before applying it. Behavior changes in this release:
ptah schema drift --format jsonreports a change to an object a feature owner plans asfeature_changes:<kind>, and an owner's access assessment asfeature_access_<effect>:<kind>, where the effect iswidened,narrowed,unchangedorunknown. These replace the categories for extensions, coordination nodes, resource pools and their classifiers, topics and topic consumers, async replications, transfers, secrets, external data sources and external tables, such asextensions_added. An extension the database lacks now readsfeature_changes:ptah.run/pgextension/extension-change. A consumer that matches category names has to accept the new form.- A YDB role that a schema declares loses the permissions it holds on a declared topic, coordination node, secret or external object that the schema does not grant.
- Row-level security with no target scope is refused on an engine other than PostgreSQL; scope it to the engine it is for.
- SQL Server security policy declarations that SQL Server cannot build are refused at parse time instead of being rendered as a comment.
ptah-compat migrate diffno longer generates changes for tables the environment excludes. When another workflow owns such a table, check it with a separate live comparison.- The provider SDK and its protocol are experimental, and later releases may change them without a migration path.
macOS binaries are ad-hoc signed, without Apple notarization. Homebrew cask downloads can carry a quarantine attribute, so Gatekeeper may refuse the first run. Verify the release checksums and Sigstore bundles before removing com.apple.quarantine from the installed ptah, ptah-compat, and ptah-ls binaries. Apple signing and notarization are tracked in #2363.