Expand description
Deployment snapshot tracking.
This module provides functionality for capturing and comparing deployment state snapshots. Instead of hashing source files, it hashes normalized compiled objects so formatting and comment changes don’t trigger unnecessary redeployments.
A deployment snapshot captures the state of all deployed objects with their content hashes, enabling change detection (like git diff but for database objects) and supporting blue/green deployment workflows.
§What’s Hashed
Content hashes are computed by compute_typed_hash from the compiled AST
representation of each object, not the source SQL file contents. The hash
includes:
- The main CREATE statement (via
Hashon the AST node) - All indexes (sorted deterministically by cluster, on_name, name, key_parts)
Hashing uses SHA-256 (via a Sha256Hasher bridge to std::hash::Hash)
for cross-platform stability. The output format is sha256:<hex>.
Key Insight: Because the hash is computed from the parsed AST, changes that are syntactically equivalent (whitespace, comment edits, identifier casing) produce identical hashes and do not trigger redeployment.
§Apply-Managed Exclusions
Tables, table-from-source, sources, secrets, and connections are excluded
from snapshots by build_snapshot_from_planned because they are managed
by the apply command path and should not participate in deployment hash
change detection.
§Snapshot Storage
Snapshots are persisted in the _mz_deploy database:
_mz_deploy.public.deployments— per-schema deployment metadata_mz_deploy.public.objects— per-object content hashes (append-only)
Structs§
- Deployment
Metadata - Metadata collected during deployment.
- Deployment
Snapshot - Represents a point-in-time snapshot of deployment state.
- Sha256
Hasher 🔒 - A wrapper that bridges
std::hash::Hashertosha2::Digest.
Enums§
- Deployment
Snapshot Error - Error types for deployment snapshot operations.
Functions§
- build_
snapshot_ 🔒from_ planned - Build a deployment snapshot from a project graph by hashing all compiled objects.
- compute_
typed_ 🔒hash - Compute a deterministic hash of a typed DatabaseObject. The hash includes:
- load_
from_ 🔒database - Load the current deployment state snapshot from the database for a specific environment.
- write_
to_ 🔒database - Write deployment snapshot to the database using the normalized schema.