Skip to main content

easy_sql/database_structs/
table_field.rs

1/// Column definition used by drivers to build tables and migrations.
2///
3/// This struct is used when calling [`Driver::create_table`](crate::Driver::create_table) and
4/// within [`AlterTableSingle::AddColumn`](crate::driver::AlterTableSingle::AddColumn). Driver backends
5/// map the fields to SQL column definitions appropriate for their dialect.
6///
7#[derive(Debug)]
8pub struct TableField {
9    /// Column name as it should appear in SQL.
10    pub name: &'static str,
11    /// Database-specific type name (e.g. `TEXT`, `INTEGER`, `UUID`).
12    pub data_type: String,
13    /// Whether to add a `UNIQUE` constraint.
14    pub is_unique: bool,
15    /// Whether to add a `NOT NULL` constraint.
16    pub is_not_null: bool,
17    /// Optional SQL literal used as `DEFAULT` value.
18    pub default: Option<String>,
19    /// Whether the column should auto-increment (driver-specific behavior).
20    pub is_auto_increment: bool,
21}