pub struct Column { /* private fields */ }Expand description
One column, described.
Returned by every Blueprint column method so modifiers chain:
ⓘ
table.string("email").unique();
table.text("bio").nullable();
table.integer("hits").default(0);Implementations§
Source§impl Column
impl Column
Sourcepub fn nullable(&mut self) -> &mut Self
pub fn nullable(&mut self) -> &mut Self
Allow NULL.
Columns are NOT NULL by default, which is the opposite of SQL’s
default — nullability should be a decision
somebody made, not one they got by omission.
Sourcepub fn default(&mut self, value: impl Into<Value>) -> &mut Self
pub fn default(&mut self, value: impl Into<Value>) -> &mut Self
A default value. Also backfills existing rows when a NOT NULL column
is added to a table that already has some.
Sourcepub fn auto_increment(&mut self) -> &mut Self
pub fn auto_increment(&mut self) -> &mut Self
Let the database assign it. Implies primary.
Sourcepub fn constrained_on(&mut self, table: impl Into<String>) -> &mut Self
pub fn constrained_on(&mut self, table: impl Into<String>) -> &mut Self
Point this column at table’s primary key.
The referenced column defaults to id; say otherwise with
references.
Sourcepub fn references(
&mut self,
table: impl Into<String>,
column: impl Into<String>,
) -> &mut Self
pub fn references( &mut self, table: impl Into<String>, column: impl Into<String>, ) -> &mut Self
Point this column at table.column.
Sourcepub fn cascade_on_delete(&mut self) -> &mut Self
pub fn cascade_on_delete(&mut self) -> &mut Self
Delete the referencing rows when the referenced row goes.
Sourcepub fn null_on_delete(&mut self) -> &mut Self
pub fn null_on_delete(&mut self) -> &mut Self
NULL the referencing column when the referenced row goes. The column
has to be nullable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Column
impl RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnsafeUnpin for Column
impl UnwindSafe for Column
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