sea_query/backend/postgres/
extension.rs

1use super::*;
2use crate::extension::postgres::*;
3
4impl ExtensionBuilder for PostgresQueryBuilder {
5    fn prepare_extension_create_statement(
6        &self,
7        create: &ExtensionCreateStatement,
8        sql: &mut dyn SqlWriter,
9    ) {
10        write!(sql, "CREATE EXTENSION ").unwrap();
11
12        if create.if_not_exists {
13            write!(sql, "IF NOT EXISTS ").unwrap()
14        }
15
16        write!(sql, "{}", create.name).unwrap();
17
18        if let Some(schema) = create.schema.as_ref() {
19            write!(sql, " WITH SCHEMA {}", schema).unwrap();
20        }
21
22        if let Some(version) = create.version.as_ref() {
23            write!(sql, " VERSION {}", version).unwrap();
24        }
25
26        if create.cascade {
27            write!(sql, " CASCADE").unwrap();
28        }
29    }
30
31    fn prepare_extension_drop_statement(
32        &self,
33        drop: &ExtensionDropStatement,
34        sql: &mut dyn SqlWriter,
35    ) {
36        write!(sql, "DROP EXTENSION ").unwrap();
37
38        if drop.if_exists {
39            write!(sql, "IF EXISTS ").unwrap();
40        }
41
42        write!(sql, "{}", drop.name).unwrap();
43
44        if drop.cascade {
45            write!(sql, " CASCADE").unwrap();
46        }
47
48        if drop.restrict {
49            write!(sql, " RESTRICT").unwrap();
50        }
51    }
52}