systemprompt_cli/commands/admin/setup/
ddl.rs1#[must_use]
9pub fn quote_ident(ident: &str) -> String {
10 format!("\"{}\"", ident.replace('"', "\"\""))
11}
12
13#[must_use]
15pub fn quote_literal(value: &str) -> String {
16 format!("'{}'", value.replace('\'', "''"))
17}
18
19#[must_use]
20pub fn build_create_user_sql(user: &str, password: &str) -> String {
21 format!(
22 "CREATE USER {} WITH PASSWORD {}",
23 quote_ident(user),
24 quote_literal(password)
25 )
26}
27
28#[must_use]
29pub fn build_create_db_sql(database: &str, owner: &str) -> String {
30 format!(
31 "CREATE DATABASE {} OWNER {}",
32 quote_ident(database),
33 quote_ident(owner)
34 )
35}
36
37#[must_use]
38pub fn build_grant_sql(database: &str, user: &str) -> String {
39 format!(
40 "GRANT ALL PRIVILEGES ON DATABASE {} TO {}",
41 quote_ident(database),
42 quote_ident(user)
43 )
44}