Attribute Macro orm_column

Source
#[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 definition
  • not_null - Add NOT NULL constraint
  • unique - Add UNIQUE constraint
  • primary_key - Mark as PRIMARY KEY
  • auto_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,
}