sea_query/backend/postgres/
extension.rs1use 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 sql.write_str("CREATE EXTENSION ").unwrap();
11
12 if create.if_not_exists {
13 sql.write_str("IF NOT EXISTS ").unwrap();
14 }
15
16 sql.write_str(&create.name).unwrap();
17
18 if let Some(schema) = create.schema.as_ref() {
19 sql.write_str(" WITH SCHEMA ").unwrap();
20 sql.write_str(schema).unwrap()
21 }
22
23 if let Some(version) = create.version.as_ref() {
24 sql.write_str(" VERSION ").unwrap();
25 sql.write_str(version).unwrap();
26 }
27
28 if create.cascade {
29 sql.write_str(" CASCADE").unwrap();
30 }
31 }
32
33 fn prepare_extension_drop_statement(
34 &self,
35 drop: &ExtensionDropStatement,
36 sql: &mut dyn SqlWriter,
37 ) {
38 sql.write_str("DROP EXTENSION ").unwrap();
39
40 if drop.if_exists {
41 sql.write_str("IF EXISTS ").unwrap();
42 }
43
44 sql.write_str(&drop.name).unwrap();
45
46 if drop.cascade {
47 sql.write_str(" CASCADE").unwrap();
48 }
49
50 if drop.restrict {
51 sql.write_str(" RESTRICT").unwrap();
52 }
53 }
54}