diff --git a/src/entities/groups.rs b/src/entities/groups.rs new file mode 100644 index 0000000..374bbd2 --- /dev/null +++ b/src/entities/groups.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "groups")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub name: String, + pub description: String, + pub order: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::track2_groups::Entity")] + Track2Groups, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Track2Groups.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/mod.rs b/src/entities/mod.rs new file mode 100644 index 0000000..7a309af --- /dev/null +++ b/src/entities/mod.rs @@ -0,0 +1,8 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub mod prelude; + +pub mod groups; +pub mod ticks; +pub mod track2_groups; +pub mod tracks; diff --git a/src/entities/prelude.rs b/src/entities/prelude.rs new file mode 100644 index 0000000..796df22 --- /dev/null +++ b/src/entities/prelude.rs @@ -0,0 +1,6 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub use super::groups::Entity as Groups; +pub use super::ticks::Entity as Ticks; +pub use super::track2_groups::Entity as Track2Groups; +pub use super::tracks::Entity as Tracks; diff --git a/src/entities/ticks.rs b/src/entities/ticks.rs new file mode 100644 index 0000000..59de347 --- /dev/null +++ b/src/entities/ticks.rs @@ -0,0 +1,38 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "ticks")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub track_id: Option, + pub year: Option, + pub month: Option, + pub day: Option, + pub hour: Option, + pub minute: Option, + pub second: Option, + pub has_time_info: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::tracks::Entity", + from = "Column::TrackId", + to = "super::tracks::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + Tracks, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Tracks.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/track2_groups.rs b/src/entities/track2_groups.rs new file mode 100644 index 0000000..5f950ad --- /dev/null +++ b/src/entities/track2_groups.rs @@ -0,0 +1,46 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "track2_groups")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub track_id: i32, + pub group_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::groups::Entity", + from = "Column::GroupId", + to = "super::groups::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + Groups, + #[sea_orm( + belongs_to = "super::tracks::Entity", + from = "Column::TrackId", + to = "super::tracks::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + Tracks, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Groups.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Tracks.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/tracks.rs b/src/entities/tracks.rs new file mode 100644 index 0000000..57d360b --- /dev/null +++ b/src/entities/tracks.rs @@ -0,0 +1,39 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "tracks")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub name: String, + pub description: String, + pub icon: String, + pub enabled: i32, + pub multiple_entries_per_day: Option, + pub color: Option, + pub order: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::ticks::Entity")] + Ticks, + #[sea_orm(has_many = "super::track2_groups::Entity")] + Track2Groups, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Ticks.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Track2Groups.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/main.rs b/src/main.rs index 79d24ea..d9344bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![feature(default_free_fn)] mod db; +mod entities; mod error; mod migrator; use error::Result;