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