worktree.rs

 1use super::ProjectId;
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "worktrees")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub id: i64,
 9    #[sea_orm(primary_key)]
10    pub project_id: ProjectId,
11    pub abs_path: String,
12    pub root_name: String,
13    pub visible: bool,
14    pub scan_id: i64,
15    pub is_complete: bool,
16}
17
18#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19pub enum Relation {
20    #[sea_orm(
21        belongs_to = "super::project::Entity",
22        from = "Column::ProjectId",
23        to = "super::project::Column::Id"
24    )]
25    Project,
26}
27
28impl Related<super::project::Entity> for Entity {
29    fn to() -> RelationDef {
30        Relation::Project.def()
31    }
32}
33
34impl ActiveModelBehavior for ActiveModel {}