Skip to main content
Ordinary sqb compile validates authored contracts offline. When adopting an existing physical schema, sqb contract performs an explicit online, read-only inspection and compares warehouse columns with repository declarations.
The target named by --from supplies the database and schema namespace to inspect. SQLBuild uses the active project connection and never resolves a second set of origin credentials.

Preview and write

contract diff reports differences and returns exit code 1 when declarations and physical relations disagree. contract generate prints the proposed declaration changes.
Without --write, no files change. Contract commands never mutate warehouse relations, lifecycle state, or fingerprints.

Safety rules

  • Additive generation preserves existing types on conflict, repository-only columns, comments, descriptions, audits, nullability, enums, tags, freshness, and loader configuration.
  • --overwrite is an explicit repository replacement policy, not a warehouse write.
  • Generation does not add contract enforced; contract activation remains an authored decision.
  • A shared SCHEMA() is not changed from one model’s evidence. Ownership conflicts are reported.
  • Writes are atomic and SQLBuild recompiles the project, restoring prior contents if validation fails.
  • Sources are first-class selectable resources, for example --select source:raw_orders.

Semantic validation

Enforced upstream contracts are authoritative compile-time interfaces. When input evidence is complete, missing or ambiguous columns fail in projections, joins, filters, grouping, windows, and ordering. Partial or opaque schemas remain open; SQLBuild does not turn missing metadata into a false error. Use sqb lineage <model> --include-uses --format json to inspect direct non-projection column uses such as join_on, where, group_by, and window_order_by. These direct-use facts are distinct from value-producing column-lineage edges. See Model Contracts and sqb contract.