Compiles and verifies flow definitions before an Elixir worker registers.
Worker startup always calls upstream pgflow.ensure_flow_compiled/4, preserves
Elixir-specific metadata such as flow_type, and only then registers the worker
function with pgflow.track_worker_function/2 using the process start mode.
Summary
Functions
Ensures the database definition matches the compiled Elixir definition and registers the worker function for monitoring.
Functions
@spec prepare(Ecto.Repo.t(), PgFlow.Flow.Definition.t()) :: {:ok, %{queue_name: String.t(), compilation_status: String.t()}} | {:error, term()}
Ensures the database definition matches the compiled Elixir definition and registers the worker function for monitoring.
Returns {:ok, %{queue_name: queue_name, compilation_status: status}} when
compilation, verification, or local recompilation succeeds. Shape mismatches
in production return {:error, {:flow_shape_mismatch, differences}}. A flow
already compiled in step mode returns
{:error, {:unsupported_queue_mode, slug, mode}} before compilation, so a
local database cannot convert it to flow mode. The mode check and the
compilation share one transaction under the upstream flow definition
advisory lock, so a concurrent step-mode compile of the same slug is either
visible to the check or waits for this worker. Missing or incompatible
schema objects return {:error, {:schema_incompatible, key}}.