feat: Add user role entity and integrate with user model, including migration updates and a new Makefile target.

This commit is contained in:
2025-12-18 20:23:03 +05:30
parent 42b567f0ac
commit f9f6871ee5
5 changed files with 62 additions and 5 deletions

View File

@@ -18,6 +18,9 @@ pub struct Model {
#[sea_orm(unique)]
pub email: String,
/// Foreign key to roles table
pub role_id: i32,
pub created_at: DateTime,
pub updated_at: DateTime,
}
@@ -26,6 +29,13 @@ pub struct Model {
pub enum Relation {
#[sea_orm(has_many = "super::session::Entity")]
Sessions,
#[sea_orm(
belongs_to = "super::role::Entity",
from = "Column::RoleId",
to = "super::role::Column::Id"
)]
Role,
}
impl Related<super::session::Entity> for Entity {
@@ -34,4 +44,11 @@ impl Related<super::session::Entity> for Entity {
}
}
impl Related<super::role::Entity> for Entity {
fn to() -> RelationDef {
Relation::Role.def()
}
}
impl ActiveModelBehavior for ActiveModel {}