Use mz-deploy to manage Materialize
View as Markdownmz-deploy is a v0.1 release and is not yet recommended for production use.
mz-deploy is a CLI that manages your Materialize deployment from plain SQL
files in a git repository. It catches errors before they reach production, lets
you test view logic locally, and deploys changes without downtime.
Installation
On macOS and Linux, we recommend installing mz-deploy with
Homebrew:
brew install materializeinc/materialize/mz-deploy
For direct downloads and other installation options, see Get started.
Why mz-deploy
Write plain SQL, deploy safely
Everything lives in .sql files — one object per file, organized by database
and schema. mz-deploy tracks dependencies between objects, diffs your project
against the live environment, and deploys only what changed. Durable objects
like secrets, connections, sources, and tables are converged in place (like
Terraform). Views, materialized views, indexes, and sinks go through a staged
deployment so changes can be validated before going live.
Catch errors before deploying
mz-deploy compile type-checks every SQL statement against your dependency
schemas — locally, with no database connection required. Inline unit tests let
you mock dependencies and verify view logic with deterministic inputs before
anything touches a real environment. Changes that break types or dependencies
fail fast on your laptop or in CI, not in production.
Ship without downtime
When you deploy, mz-deploy creates your changes in isolated staging schemas
alongside production. Once all materialized views finish computing their initial
results, a single atomic swap cuts traffic over to the new version. Running
queries are never interrupted, and if something goes wrong, the staging
deployment can be cleaned up without affecting production.
When to use it
| Tool | Best for | Manages infrastructure | Zero-downtime deployments |
|---|---|---|---|
| Plain SQL / psql scripts | Manual execution. No dependency tracking, no diff, no rollback. Where most teams start. | No | No |
| mz-deploy | SQL-native, git-based workflow with offline type-checking, unit tests, and staged deployments. | Yes | Yes |
| dbt | Teams already invested in dbt. Manages views and materialized views. | No (clusters, connections, secrets are out of scope) | Yes (via dbt-materialize adapter macros) |
| Terraform | Teams managing Materialize alongside other cloud infrastructure. | Yes | No |