worktree.rs

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