From 625da9b7af0bf3a50c9306273693ac84baac64a0 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Wed, 7 Jun 2023 08:48:44 -0400 Subject: [PATCH] generate entities --- src/entities/groups.rs | 27 ++++++++++++++++++++ src/entities/mod.rs | 8 ++++++ src/entities/prelude.rs | 6 +++++ src/entities/ticks.rs | 38 +++++++++++++++++++++++++++++ src/entities/track2_groups.rs | 46 +++++++++++++++++++++++++++++++++++ src/entities/tracks.rs | 39 +++++++++++++++++++++++++++++ src/main.rs | 1 + 7 files changed, 165 insertions(+) create mode 100644 src/entities/groups.rs create mode 100644 src/entities/mod.rs create mode 100644 src/entities/prelude.rs create mode 100644 src/entities/ticks.rs create mode 100644 src/entities/track2_groups.rs create mode 100644 src/entities/tracks.rs 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;