feat: Add user role entity and integrate with user model, including migration updates and a new Makefile target.
This commit is contained in:
@@ -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 {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user