role_permission.rs
39 lignes · 1170 octets
use sea_orm::entity::prelude::*; use uuid::Uuid; /// SeaORM model for the `role_permissions` junction table. /// /// Associates roles with permissions using a composite primary key. #[derive(Clone, Debug, DeriveEntityModel)] #[sea_orm(table_name = "role_permissions")] pub struct Model { /// FK → roles.id (part of composite primary key). #[sea_orm(primary_key)] pub role_id: Uuid, /// FK → permissions.id (part of composite primary key). #[sea_orm(primary_key)] pub permission_id: Uuid, } /// SeaORM relations for the RolePermission junction entity. #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { /// The role side of the junction. #[sea_orm( belongs_to = "super::role::Entity", from = "Column::RoleId", to = "super::role::Column::Id", on_delete = "Cascade" )] Role, /// The permission side of the junction. #[sea_orm( belongs_to = "super::permission::Entity", from = "Column::PermissionId", to = "super::permission::Column::Id", on_delete = "Cascade" )] Permission, } impl ActiveModelBehavior for ActiveModel {}
GitRust