feat: add diet entity and user lifestyle habits with data seeding support
This commit is contained in:
@@ -31,6 +31,16 @@ pub struct Model {
|
||||
/// Date of birth
|
||||
pub birthdate: Option<Date>,
|
||||
|
||||
// Lifestyle / Habits
|
||||
/// Whether the user smokes
|
||||
pub smoking: Option<bool>,
|
||||
|
||||
/// Whether the user consumes alcohol
|
||||
pub alcohol: Option<bool>,
|
||||
|
||||
/// Foreign key to diet types
|
||||
pub diet_id: Option<i32>,
|
||||
|
||||
pub created_at: DateTime,
|
||||
pub updated_at: DateTime,
|
||||
}
|
||||
@@ -46,6 +56,13 @@ pub enum Relation {
|
||||
to = "super::role::Column::Id"
|
||||
)]
|
||||
Role,
|
||||
|
||||
#[sea_orm(
|
||||
belongs_to = "super::diet::Entity",
|
||||
from = "Column::DietId",
|
||||
to = "super::diet::Column::Id"
|
||||
)]
|
||||
Diet,
|
||||
}
|
||||
|
||||
impl Related<super::session::Entity> for Entity {
|
||||
@@ -60,5 +77,10 @@ impl Related<super::role::Entity> for Entity {
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
impl Related<super::diet::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Diet.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
||||
Reference in New Issue
Block a user