use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i32", db_type = "SmallInteger")] pub enum ProjectMemberRole { Owner = 0, Lead = 1, #[default] Contributor = 2, Viewer = 3, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "project_members")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(unique_key = "project_user")] pub project_id: Uuid, #[sea_orm(unique_key = "project_user")] pub user_id: Uuid, pub role: ProjectMemberRole, pub joined_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "project_id", to = "id")] pub project: BelongsTo, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}