Skip to main content

mz_deploy/cli/
commands.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! Command implementations for the mz-deploy CLI.
11//!
12//! Each subcommand lives in its own module and exposes a `run()` entry point
13//! that returns `Result<T, CliError>`. The [`executor`](super::executor) module
14//! dispatches to these functions after setting up configuration and connections.
15//!
16//! ## Commands
17//!
18//! - **[`new_project`]** — Scaffold a new mz-deploy project directory.
19//! - **[`compile`]** — Parse and validate the project, optionally type-checking
20//!   against a Docker container.
21//! - **[`explain`]** — Show the EXPLAIN plan for a materialized view or index.
22//! - **[`stage`]** — Deploy the project to a staging environment.
23//! - **[`wait`]** — Check hydration status of a staged deployment.
24//! - **[`promote`]** — Promote a staged deployment to production.
25//! - **[`apply_all`]** — Orchestrate all infrastructure apply steps.
26//! - **[`abort`]** — Roll back a staged deployment.
27//! - **[`apply_sources`]** — Create sources that don't exist.
28//! - **[`apply_tables`]** — Create tables that don't exist.
29//! - **[`lock`]** — Generate or refresh the `types.lock` file from
30//!   the live region.
31//! - **[`describe`]** — Print a summary of the compiled project.
32//! - **[`debug`]** — Dump internal state for troubleshooting.
33//! - **[`sql`]** — Launch an interactive psql session using the active profile.
34//! - **[`mcp`]** — Proxy stdio JSON-RPC to the developer MCP HTTP endpoint.
35//! - **[`list`]** — List active deployments.
36//! - **[`setup`]** — Initialize deployment tracking infrastructure.
37//! - **[`log`]** — Show deployment history.
38//! - **[`clusters`]** — List or inspect cluster definitions.
39//! - **[`roles`]** — List or inspect role definitions.
40//! - **[`apply_network_policies`]** — Apply network policy definitions.
41//! - **`test`** — Run SQL unit tests against cached type information.
42//!
43//! ## Shared Types
44//!
45//! - [`ObjectRef`] — A `(ObjectId, &DatabaseObject)` pair used as the canonical
46//!   unit of work when iterating over objects in dependency order.
47
48use crate::project::ir::compiled::DatabaseObject;
49use crate::project::ir::object_id::ObjectId;
50
51/// Fully-qualified object identity paired with its typed SQL representation.
52///
53/// Used across command modules as the canonical unit of work when iterating
54/// over objects in dependency order.
55pub type ObjectRef<'a> = (ObjectId, &'a DatabaseObject);
56
57pub mod abort;
58pub mod apply_all;
59pub mod apply_connections;
60pub mod apply_network_policies;
61pub mod apply_objects;
62pub mod apply_secrets;
63pub mod apply_sources;
64pub mod apply_tables;
65pub mod clean;
66pub mod clusters;
67pub mod compile;
68pub mod debug;
69pub mod delete;
70pub mod describe;
71pub mod dev;
72pub mod explain;
73pub mod grants;
74pub mod list;
75pub mod lock;
76pub mod log;
77pub mod mcp;
78pub mod new_project;
79pub mod profile;
80pub mod promote;
81pub mod roles;
82pub mod setup;
83mod setup_schema;
84pub mod sql;
85pub mod stage;
86pub mod test;
87pub mod wait;