1use crate::{SchemaStatementBuilder, TableIndex, backend::SchemaBuilder, types::*};
2
3#[derive(Default, Debug, Clone)]
29pub struct IndexDropStatement {
30 pub(crate) table: Option<TableRef>,
31 pub(crate) index: TableIndex,
32 pub(crate) if_exists: bool,
33 pub(crate) concurrently: bool,
34}
35
36impl IndexDropStatement {
37 pub fn new() -> Self {
39 Self::default()
40 }
41
42 pub fn name<T>(&mut self, name: T) -> &mut Self
44 where
45 T: Into<String>,
46 {
47 self.index.name(name);
48 self
49 }
50
51 pub fn table<T>(&mut self, table: T) -> &mut Self
53 where
54 T: IntoTableRef,
55 {
56 self.table = Some(table.into_table_ref());
57 self
58 }
59
60 pub fn if_exists(&mut self) -> &mut Self {
61 self.if_exists = true;
62 self
63 }
64
65 pub fn concurrently(&mut self) -> &mut Self {
67 self.concurrently = true;
68 self
69 }
70}
71
72impl SchemaStatementBuilder for IndexDropStatement {
73 fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
74 let mut sql = String::with_capacity(256);
75 schema_builder.prepare_index_drop_statement(self, &mut sql);
76 sql
77 }
78}
79
80impl IndexDropStatement {
81 pub fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
82 <Self as SchemaStatementBuilder>::build(self, schema_builder)
83 }
84
85 pub fn to_string<T: SchemaBuilder>(&self, schema_builder: T) -> String {
86 <Self as SchemaStatementBuilder>::to_string(self, schema_builder)
87 }
88}