Skip to main content

assert_runtime_schema_v2_compatible

Function assert_runtime_schema_v2_compatible 

Source
pub async fn assert_runtime_schema_v2_compatible(
    pool: &PgPool,
) -> Result<(), SchemaConformanceError>
Expand description

Asserts that a host database is compatible with the canonical schema-v2 contract before the host accepts billing work.

Call this after the host has applied its immutable Syrup Rail install or forward-only upgrade migration through its normal migration deployment. This function does not install, upgrade, preflight, audit, or otherwise mutate the schema. It runs the same full canonical v2 catalog conformance and fingerprint check used by the schema-contract tests in one REPEATABLE READ READ ONLY PostgreSQL transaction. PostgreSQL major version 18 is required; other majors are rejected before catalog comparison. A concurrent-reindex transition mismatch is retried once in a fresh transaction so a reindex that commits between catalog and live-operation observations cannot cause a stale result. Other contract failures are not retried.

Invalid _ccnew and _ccold shadows are tolerated only when the validating role can see matching non-initializing REINDEX CONCURRENTLY details in pg_stat_progress_create_index and the backend retains the expected table and index locks. PostgreSQL hides those details from unrelated roles without statistics privileges, for which this check deliberately fails closed.