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}
19
20#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
21pub enum Relation {
22 #[sea_orm(
23 belongs_to = "super::project::Entity",
24 from = "Column::ProjectId",
25 to = "super::project::Column::Id"
26 )]
27 Project,
28}
29
30impl Related<super::project::Entity> for Entity {
31 fn to() -> RelationDef {
32 Relation::Project.def()
33 }
34}
35
36impl ActiveModelBehavior for ActiveModel {}