pub struct ColumnDef {
pub name: Ident,
pub ty: ColumnType,
pub not_null: bool,
pub primary_key: bool,
pub auto_increment: bool,
pub unique: bool,
pub default: Option<Expr>,
pub check: Option<Expr>,
}Expand description
A column definition.
Fields§
§name: IdentThe column name.
ty: ColumnTypeThe logical type.
not_null: boolWhether NOT NULL is set.
primary_key: boolWhether the column is a single-column PRIMARY KEY.
auto_increment: boolWhether AUTOINCREMENT is set; requires an INTEGER PRIMARY KEY.
unique: boolWhether UNIQUE is set.
default: Option<Expr>The DEFAULT expr, inlined as a literal when rendered.
check: Option<Expr>The CHECK (expr) constraint.
Implementations§
Source§impl ColumnDef
impl ColumnDef
Sourcepub fn new(name: impl IntoIden, ty: ColumnType) -> Self
pub fn new(name: impl IntoIden, ty: ColumnType) -> Self
A nullable column of the given type.
Sourcepub fn string(name: impl IntoIden, len: Option<u32>) -> Self
pub fn string(name: impl IntoIden, len: Option<u32>) -> Self
A TEXT column with an advisory length.
Sourcepub fn timestamp_with_time_zone(name: impl IntoIden) -> Self
pub fn timestamp_with_time_zone(name: impl IntoIden) -> Self
A zoned timestamp column, stored as RFC 3339 text.
Sourcepub fn primary_key(self) -> Self
pub fn primary_key(self) -> Self
Sets PRIMARY KEY.
Sourcepub fn auto_increment(self) -> Self
pub fn auto_increment(self) -> Self
Sets AUTOINCREMENT.
Sourcepub fn unique_key(self) -> Self
pub fn unique_key(self) -> Self
Sets UNIQUE.
Trait Implementations§
impl StructuralPartialEq for ColumnDef
Auto Trait Implementations§
impl Freeze for ColumnDef
impl RefUnwindSafe for ColumnDef
impl Send for ColumnDef
impl Sync for ColumnDef
impl Unpin for ColumnDef
impl UnsafeUnpin for ColumnDef
impl UnwindSafe for ColumnDef
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