sea_query/foreign_key/
drop.rs1use inherent::inherent;
2
3use crate::{backend::SchemaBuilder, types::*, SchemaStatementBuilder, TableForeignKey};
4
5#[derive(Default, Debug, Clone)]
28pub struct ForeignKeyDropStatement {
29 pub(crate) foreign_key: TableForeignKey,
30 pub(crate) table: Option<TableRef>,
31}
32
33impl ForeignKeyDropStatement {
34 pub fn new() -> Self {
36 Self::default()
37 }
38
39 pub fn name<T>(&mut self, name: T) -> &mut Self
41 where
42 T: Into<String>,
43 {
44 self.foreign_key.name(name);
45 self
46 }
47
48 pub fn table<T>(&mut self, table: T) -> &mut Self
50 where
51 T: IntoTableRef,
52 {
53 self.table = Some(table.into_table_ref());
54 self
55 }
56}
57
58#[inherent]
59impl SchemaStatementBuilder for ForeignKeyDropStatement {
60 pub fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
61 let mut sql = String::with_capacity(256);
62 schema_builder.prepare_foreign_key_drop_statement(self, &mut sql);
63 sql
64 }
65
66 pub fn build_any(&self, schema_builder: &dyn SchemaBuilder) -> String {
67 let mut sql = String::with_capacity(256);
68 schema_builder.prepare_foreign_key_drop_statement(self, &mut sql);
69 sql
70 }
71
72 pub fn to_string<T: SchemaBuilder>(&self, schema_builder: T) -> String;
73}