diff --git a/operator/src/postgres.rs b/operator/src/postgres.rs index e2ca9cc..f95b04c 100644 --- a/operator/src/postgres.rs +++ b/operator/src/postgres.rs @@ -31,6 +31,7 @@ impl Postgres { let query_create_user = format!("create user \"{username}\" with password '{password}';"); let query_grant = format!("grant select on all tables in schema public to \"{username}\";"); + let query_privileges = format!("alter default privileges in schema public grant all privileges on tables to \"{username}\";"); let timeout = get_config().statement_timeout; let query_set_timeout = @@ -53,6 +54,12 @@ impl Postgres { return Err(Error::PgError(err.to_string())); } + let privileges_stmt = tx.prepare(&query_privileges).await?; + if let Err(err) = tx.execute(&privileges_stmt, &[]).await { + tx.rollback().await?; + return Err(Error::PgError(err.to_string())); + } + let set_timeout_stmt = tx.prepare(&query_set_timeout).await?; let set_timeout_result = tx.execute(&set_timeout_stmt, &[]).await; if let Err(err) = set_timeout_result {