pub struct ColumnBuilder { /* private fields */ }Expand description
Type-safe column definition builder.
Provides a fluent API for building column definitions with all constraints.
Implementations§
Source§impl ColumnBuilder
impl ColumnBuilder
Sourcepub fn new(name: impl Into<String>, data_type: DataType) -> Self
pub fn new(name: impl Into<String>, data_type: DataType) -> Self
Creates a new column builder with name and type.
Sourcepub fn primary_key(self) -> Self
pub fn primary_key(self) -> Self
Marks the column as PRIMARY KEY.
Sourcepub fn autoincrement(self) -> Self
pub fn autoincrement(self) -> Self
Marks the column as AUTOINCREMENT.
Sourcepub fn default_bool(self, value: bool) -> Self
pub fn default_bool(self, value: bool) -> Self
Sets a boolean default value.
Sourcepub fn default_int(self, value: i64) -> Self
pub fn default_int(self, value: i64) -> Self
Sets an integer default value.
Sourcepub fn default_float(self, value: f64) -> Self
pub fn default_float(self, value: f64) -> Self
Sets a float default value.
Sourcepub fn default_str(self, value: impl Into<String>) -> Self
pub fn default_str(self, value: impl Into<String>) -> Self
Sets a string default value.
Sourcepub fn default_null(self) -> Self
pub fn default_null(self) -> Self
Sets a NULL default value.
Sourcepub fn default_expr(self, expr: impl Into<String>) -> Self
pub fn default_expr(self, expr: impl Into<String>) -> Self
Sets a raw SQL expression as default (e.g., CURRENT_TIMESTAMP).
Sourcepub fn references(
self,
table: impl Into<String>,
column: impl Into<String>,
) -> Self
pub fn references( self, table: impl Into<String>, column: impl Into<String>, ) -> Self
Sets a foreign key reference.
Sourcepub fn references_on_delete(
self,
table: impl Into<String>,
column: impl Into<String>,
on_delete: ForeignKeyAction,
) -> Self
pub fn references_on_delete( self, table: impl Into<String>, column: impl Into<String>, on_delete: ForeignKeyAction, ) -> Self
Sets a foreign key reference with ON DELETE action.
Sourcepub fn references_full(
self,
table: impl Into<String>,
column: impl Into<String>,
on_delete: Option<ForeignKeyAction>,
on_update: Option<ForeignKeyAction>,
) -> Self
pub fn references_full( self, table: impl Into<String>, column: impl Into<String>, on_delete: Option<ForeignKeyAction>, on_update: Option<ForeignKeyAction>, ) -> Self
Sets a foreign key reference with full options.
Sourcepub fn collation(self, collation: impl Into<String>) -> Self
pub fn collation(self, collation: impl Into<String>) -> Self
Sets the collation for string columns.
Sourcepub fn build(self) -> ColumnDefinition
pub fn build(self) -> ColumnDefinition
Builds the column definition.
Trait Implementations§
Source§impl Clone for ColumnBuilder
impl Clone for ColumnBuilder
Source§fn clone(&self) -> ColumnBuilder
fn clone(&self) -> ColumnBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ColumnBuilder
impl RefUnwindSafe for ColumnBuilder
impl Send for ColumnBuilder
impl Sync for ColumnBuilder
impl Unpin for ColumnBuilder
impl UnwindSafe for ColumnBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more