#[orm_column]
Expand description
Column attribute macro for defining SQL column properties
This attribute allows you to specify custom SQL column properties for struct fields.
§Supported attributes:
type = "SQL_TYPE"
- Custom SQL type definitionnot_null
- Add NOT NULL constraintunique
- Add UNIQUE constraintprimary_key
- Mark as PRIMARY KEYauto_increment
- Add AUTOINCREMENT (for INTEGER PRIMARY KEY)
§Examples:
#[derive(Model)]
struct User {
#[orm_column(type = "INTEGER PRIMARY KEY AUTOINCREMENT")]
pub id: Option<i64>,
#[orm_column(not_null, unique)]
pub email: String,
#[orm_column(type = "TEXT DEFAULT 'active'")]
pub status: String,
}