Skip to main content

mz_deploy/cli/commands/
apply_objects.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//! Shared helpers for apply commands that reconcile grants/comments on database objects.
11
12use crate::cli::CliError;
13use crate::cli::commands::grants;
14use crate::cli::executor::DeploymentExecutor;
15use crate::client::Client;
16use crate::project::ir::compiled;
17use crate::project::ir::object_id::ObjectId;
18
19/// Reconcile grants and execute comment statements for one database object.
20pub async fn reconcile_grants_and_comments(
21    client: &Client,
22    executor: &DeploymentExecutor<'_>,
23    obj_id: &ObjectId,
24    typed_obj: &compiled::DatabaseObject,
25    grant_kind: &grants::GrantObjectKind,
26) -> Result<(), CliError> {
27    grants::reconcile(client, executor, obj_id, &typed_obj.grants, grant_kind).await?;
28    for comment in &typed_obj.comments {
29        executor.execute_sql(comment).await?;
30    }
31    Ok(())
32}