PgFlow.Upstream.Bundle (PgFlow v0.7.2)

Copy Markdown View Source

Builds a deterministic core SQL delta from a versioned upstream spec.

Published versions stay frozen. V02's import rules live in PgFlow.Upstream.Spec.V02 and are not rebuilt. The next import is core V03.

Summary

Functions

Builds SQL and a provenance manifest for one core delta version.

Core versions whose generated SQL must not be rewritten.

Wraps a start_tasks definition so it installs the seven-column body or the eight-column attempts_count body, depending on pgflow.step_task_record.

Same dispatch as shape_dispatch/1, plus the eight-column function body.

Accepts a version that has a loaded spec and is not published.

Types

bundle()

@type bundle() :: %{
  :sql => String.t(),
  :manifest => map(),
  optional(:fragment) => String.t()
}

Functions

build(checkout, sha, version, opts \\ [])

@spec build(Path.t(), String.t(), String.t(), keyword()) ::
  {:ok, bundle()} | {:error, String.t()}

Builds SQL and a provenance manifest for one core delta version.

Published versions and unknown versions return {:error, message} without reading the checkout.

opts accepts :v02_sql, the core V02 script used to prove omission pairs still describe the published SQL. The default is the committed v02_up.sql.

published_versions()

@spec published_versions() :: [String.t()]

Core versions whose generated SQL must not be rewritten.

shape_dispatch(seven_column_sql)

@spec shape_dispatch(String.t()) :: {:ok, String.t()} | {:error, String.t()}

Wraps a start_tasks definition so it installs the seven-column body or the eight-column attempts_count body, depending on pgflow.step_task_record.

shape_dispatch_parts(seven_column_sql)

@spec shape_dispatch_parts(String.t()) ::
  {:ok, String.t(), %{fragment: String.t()}} | {:error, String.t()}

Same dispatch as shape_dispatch/1, plus the eight-column function body.

The fragment is that body with the quoted "pgflow". qualifier rewritten to $SCHEMA$., which is the helpers placeholder used by the V02 fragment.

validate_version(version, published \\ ["01", "02"])

@spec validate_version(String.t(), [String.t()]) :: :ok | {:error, String.t()}

Accepts a version that has a loaded spec and is not published.

published defaults to the frozen core versions. The mix task passes its own copy so the two lists stay wired together.