pub struct ColumnDef {
pub name: &'static str,
pub data_type: DataTypeKind,
pub auto_increment: bool,
pub nullable: bool,
pub primary_key: bool,
pub unique: bool,
pub foreign_key: Option<ForeignKeyDef>,
pub default: Option<fn() -> Value>,
pub renamed_from: &'static [&'static str],
}Expand description
Defines a column in a database table.
Fields§
§name: &'static strThe name of the column.
data_type: DataTypeKindThe data type of the column.
auto_increment: boolIndicates if this column is auto-incrementing (applicable for integer types).
Cannot be nullable.
nullable: boolIndicates if this column can contain NULL values.
primary_key: boolIndicates if this column is part of the primary key.
unique: boolIndicates if this column has unique values across all records.
foreign_key: Option<ForeignKeyDef>Foreign key definition, if any.
default: Option<fn() -> Value>Default value constructor, if any.
Populated by the #[default = ...] attribute on a #[derive(Table)]
field. Consumed by the migration planner when adding a non-nullable
column to satisfy the
DefaultMissing
check.
renamed_from: &'static [&'static str]Previous names this column was known by, in chronological order.
Populated by the #[renamed_from("old1", "old2", ...)] attribute. The
migration planner walks this list to detect a RenameColumn op when a
stored column with one of these names matches the compiled column.