(toggl-portal): Add project <-> time_entry fk relation

This commit is contained in:
2023-11-06 20:13:13 +00:00
parent 64570190c8
commit 3eb3316c31
4 changed files with 67 additions and 1 deletions
+8
View File
@@ -28,6 +28,8 @@ pub enum Relation {
on_delete = "NoAction"
)]
Client,
#[sea_orm(has_many = "super::time_entry::Entity")]
TimeEntry,
}
impl Related<super::client::Entity> for Entity {
@@ -36,4 +38,10 @@ impl Related<super::client::Entity> for Entity {
}
}
impl Related<super::time_entry::Entity> for Entity {
fn to() -> RelationDef {
Relation::TimeEntry.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
+16 -1
View File
@@ -19,6 +19,21 @@ pub struct Model {
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {
#[sea_orm(
belongs_to = "super::project::Entity",
from = "Column::ProjectId",
to = "super::project::Column::TogglId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Project,
}
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::Project.def()
}
}
impl ActiveModelBehavior for ActiveModel {}