From 7576b18b14720708f2873083c50874da913eaf27 Mon Sep 17 00:00:00 2001 From: Anastasia Lubennikova Date: Tue, 18 Oct 2022 14:45:51 +0300 Subject: [PATCH] [compute_tools] fix GRANT CREATE ON SCHEMA public - run the grant query in each database --- compute_tools/src/spec.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compute_tools/src/spec.rs b/compute_tools/src/spec.rs index 89a6a93510..84d72714db 100644 --- a/compute_tools/src/spec.rs +++ b/compute_tools/src/spec.rs @@ -380,10 +380,6 @@ pub fn handle_grants(node: &ComputeNode, client: &mut Client) -> Result<()> { info!("grant query {}", &query); client.execute(query.as_str(), &[])?; - - // Explicitly grant CREATE ON SCHEMA PUBLIC to the web_access user. - // This is needed since postgres 15, where this privilege is removed by default. - client.execute("GRANT CREATE ON SCHEMA public TO web_access", &[])?; } // Do some per-database access adjustments. We'd better do this at db creation time, @@ -426,6 +422,12 @@ pub fn handle_grants(node: &ComputeNode, client: &mut Client) -> Result<()> { db.owner.quote() ); db_client.simple_query(&alter_query)?; + + // Explicitly grant CREATE ON SCHEMA PUBLIC to the web_access user. + // This is needed since postgres 15, where this privilege is removed by default. + let grant_query: String = "GRANT CREATE ON SCHEMA public TO web_access".to_string(); + info!("grant query for db {} : {}", &db.name, &grant_query); + db_client.simple_query(&grant_query)?; } Ok(())