(toggl-portal): Add projects to database

This commit is contained in:
2023-11-06 20:03:26 +00:00
parent 84cb5f5379
commit 8e9f8538de
6 changed files with 115 additions and 1 deletions
+10 -1
View File
@@ -16,6 +16,15 @@ pub struct Model {
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {
#[sea_orm(has_many = "super::project::Entity")]
Project,
}
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::Project.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
+1
View File
@@ -3,5 +3,6 @@
pub mod prelude;
pub mod client;
pub mod project;
pub mod time_entry;
pub mod toggl_portal_seaql_migrations;
+1
View File
@@ -1,5 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
pub use super::client::Entity as Client;
pub use super::project::Entity as Project;
pub use super::time_entry::Entity as TimeEntry;
pub use super::toggl_portal_seaql_migrations::Entity as TogglPortalSeaqlMigrations;
+37
View File
@@ -0,0 +1,37 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "project")]
pub struct Model {
pub id: i32,
pub toggl_id: i64,
pub workspace_id: i64,
pub client_id: Option<i32>,
pub name: String,
pub active: bool,
#[sea_orm(column_type = "JsonBinary")]
pub raw_json: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::client::Entity",
from = "Column::ClientId",
to = "super::client::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Client,
}
impl Related<super::client::Entity> for Entity {
fn to() -> RelationDef {
Relation::Client.def()
}
}
impl ActiveModelBehavior for ActiveModel {}