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, validate, and type-check the project locally.
20//! - **[`explain`]** — Show the EXPLAIN plan for a materialized view or index.
21//! - **[`stage`]** — Deploy the project to a staging environment.
22//! - **[`wait`]** — Check hydration status of a staged deployment.
23//! - **[`promote`]** — Promote a staged deployment to production.
24//! - **[`apply_all`]** — Orchestrate all infrastructure apply steps.
25//! - **[`abort`]** — Roll back a staged deployment.
26//! - **[`apply_sources`]** — Create sources that don't exist.
27//! - **[`apply_tables`]** — Create tables that don't exist.
28//! - **[`lock`]** — Generate or refresh the `types.lock` file from
29//! the live region.
30//! - **[`describe`]** — Print a summary of the compiled project.
31//! - **[`debug`]** — Dump internal state for troubleshooting.
32//! - **[`sql`]** — Launch an interactive psql session using the active profile.
33//! - **[`mcp`]** — Proxy stdio JSON-RPC to the developer MCP HTTP endpoint.
34//! - **[`list`]** — List active deployments.
35//! - **[`setup`]** — Initialize deployment tracking infrastructure.
36//! - **[`log`]** — Show deployment history.
37//! - **[`clusters`]** — List or inspect cluster definitions.
38//! - **[`roles`]** — List or inspect role definitions.
39//! - **[`apply_network_policies`]** — Apply network policy definitions.
40//! - **`test`** — Run SQL unit tests against cached type information.
41//!
42//! ## Shared Types
43//!
44//! - [`ObjectRef`] — A `(ObjectId, &DatabaseObject)` pair used as the canonical
45//! unit of work when iterating over objects in dependency order.
46
47use crate::project::ir::compiled::DatabaseObject;
48use crate::project::ir::object_id::ObjectId;
49
50/// Fully-qualified object identity paired with its typed SQL representation.
51///
52/// Used across command modules as the canonical unit of work when iterating
53/// over objects in dependency order.
54pub type ObjectRef<'a> = (ObjectId, &'a DatabaseObject);
55
56pub mod abort;
57pub mod apply_all;
58pub mod apply_connections;
59pub mod apply_network_policies;
60pub mod apply_objects;
61pub mod apply_secrets;
62pub mod apply_sources;
63pub mod apply_tables;
64pub mod clean;
65pub mod clusters;
66pub mod compile;
67pub mod debug;
68pub mod delete;
69pub mod describe;
70pub mod dev;
71pub mod explain;
72pub mod grants;
73pub mod list;
74pub mod lock;
75pub mod log;
76pub mod mcp;
77pub mod new_project;
78pub mod profile;
79pub mod promote;
80pub mod roles;
81pub mod setup;
82mod setup_schema;
83pub mod sql;
84pub mod stage;
85pub mod test;
86pub mod wait;