worktree.rs

 1use crate::db::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    /// The last scan for which we've observed entries. It may be in progress.
15    pub scan_id: i64,
16    /// The last scan that fully completed.
17    pub completed_scan_id: i64,
18    pub root_repo_common_dir: Option<String>,
19}
20
21#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
22pub enum Relation {
23    #[sea_orm(
24        belongs_to = "super::project::Entity",
25        from = "Column::ProjectId",
26        to = "super::project::Column::Id"
27    )]
28    Project,
29}
30
31impl Related<super::project::Entity> for Entity {
32    fn to() -> RelationDef {
33        Relation::Project.def()
34    }
35}
36
37impl ActiveModelBehavior for ActiveModel {}