-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rerun seaORM CLI for generating entities
- Loading branch information
1 parent
42acde4
commit bf56dba
Showing
12 changed files
with
137 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3 | ||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] | ||
#[sea_orm( | ||
schema_name = "refactor_platform", | ||
table_name = "coaching_relationships" | ||
)] | ||
pub struct Model { | ||
#[sea_orm(primary_key)] | ||
#[serde(skip_deserializing)] | ||
pub id: i32, | ||
#[sea_orm(unique)] | ||
pub external_id: Uuid, | ||
pub organization_id: i32, | ||
pub coach_id: i32, | ||
pub coachee_id: i32, | ||
pub created_at: Option<DateTimeWithTimeZone>, | ||
pub updated_at: Option<DateTimeWithTimeZone>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
pub enum Relation { | ||
#[sea_orm( | ||
belongs_to = "super::organizations::Entity", | ||
from = "Column::OrganizationId", | ||
to = "super::organizations::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
Organizations, | ||
#[sea_orm( | ||
belongs_to = "super::users::Entity", | ||
from = "Column::CoachId", | ||
to = "super::users::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
Users2, | ||
#[sea_orm( | ||
belongs_to = "super::users::Entity", | ||
from = "Column::CoacheeId", | ||
to = "super::users::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
Users1, | ||
} | ||
|
||
impl Related<super::organizations::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::Organizations.def() | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
pub mod coaching_relationship; | ||
pub mod organization; | ||
pub mod user; | ||
pub mod prelude; | ||
|
||
pub mod actions; | ||
pub mod agreements; | ||
pub mod coaching_relationships; | ||
pub mod coaching_sessions; | ||
pub mod notes; | ||
pub mod organizations; | ||
pub mod overarching_goals; | ||
pub mod users; | ||
|
||
/// A type alias that represents any Entity's id field data type | ||
pub type Id = i32; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3 | ||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] | ||
#[sea_orm(schema_name = "refactor_platform", table_name = "organizations")] | ||
pub struct Model { | ||
#[sea_orm(primary_key)] | ||
#[serde(skip_deserializing)] | ||
pub id: i32, | ||
#[sea_orm(unique)] | ||
pub external_id: Uuid, | ||
pub name: Option<String>, | ||
pub logo: Option<String>, | ||
pub created_at: Option<DateTimeWithTimeZone>, | ||
pub updated_at: Option<DateTimeWithTimeZone>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
pub enum Relation { | ||
#[sea_orm(has_many = "super::coaching_relationships::Entity")] | ||
CoachingRelationships, | ||
} | ||
|
||
impl Related<super::coaching_relationships::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::CoachingRelationships.def() | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3 | ||
pub use super::actions::Entity as Actions; | ||
pub use super::agreements::Entity as Agreements; | ||
pub use super::coaching_sessions::Entity as CoachingSessions; | ||
pub use super::notes::Entity as Notes; | ||
pub use super::overarching_goals::Entity as OverarchingGoals; | ||
pub use super::seaql_migrations::Entity as SeaqlMigrations; | ||
pub use super::coaching_relationships::Entity as CoachingRelationships; | ||
pub use super::organizations::Entity as Organizations; | ||
pub use super::users::Entity as Users; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use async_trait::async_trait; | ||
use axum_login::{AuthnBackend, UserId}; | ||
use entity::user::{self, Column, Model}; | ||
use entity::users::*; | ||
use log::*; | ||
use password_auth::{generate_hash, verify_password}; | ||
use sea_orm::{entity::prelude::*, sea_query, ActiveValue, DatabaseConnection}; | ||
|
@@ -57,7 +57,7 @@ impl AuthnBackend for Backend { | |
async fn get_user(&self, user_id: &UserId<Self>) -> Result<Option<Self::User>, Self::Error> { | ||
debug!("** get_user(): {:?}", *user_id); | ||
|
||
let user: Option<Self::User> = entity::user::Entity::find_by_id(*user_id) | ||
let user: Option<Self::User> = entity::users::Entity::find_by_id(*user_id) | ||
.one(self.db.as_ref()) | ||
.await?; | ||
|
||
|
@@ -71,9 +71,10 @@ pub type AuthSession = axum_login::AuthSession<Backend>; | |
|
||
pub(crate) async fn seed_database(db: &DatabaseConnection) { | ||
let users = vec![ | ||
user::ActiveModel { | ||
ActiveModel { | ||
id: ActiveValue::NotSet, | ||
email: ActiveValue::Set("[email protected]".to_owned()), | ||
external_id: ActiveValue::Set(uuid::Uuid::new_v4()), | ||
first_name: ActiveValue::Set("Jim".to_owned()), | ||
last_name: ActiveValue::Set("Hodapp".to_owned()), | ||
display_name: ActiveValue::Set("Jim H".to_owned()), | ||
|
@@ -83,9 +84,10 @@ pub(crate) async fn seed_database(db: &DatabaseConnection) { | |
created_at: ActiveValue::NotSet, | ||
updated_at: ActiveValue::NotSet, | ||
}, | ||
user::ActiveModel { | ||
ActiveModel { | ||
id: ActiveValue::NotSet, | ||
email: ActiveValue::Set("[email protected]".to_owned()), | ||
external_id: ActiveValue::Set(uuid::Uuid::new_v4()), | ||
first_name: ActiveValue::Set("Test First".to_owned()), | ||
last_name: ActiveValue::Set("Test Last".to_owned()), | ||
display_name: ActiveValue::Set("Test User".to_owned()), | ||
|
@@ -101,13 +103,13 @@ pub(crate) async fn seed_database(db: &DatabaseConnection) { | |
debug!("user: {:?}", user); | ||
|
||
// Upserts seeded user data: | ||
match user::Entity::insert(user) | ||
match users::Entity::insert(user) | ||
.on_conflict( | ||
// on conflict do update | ||
sea_query::OnConflict::column(user::Column::Email) | ||
.update_column(user::Column::FirstName) | ||
.update_column(user::Column::LastName) | ||
.update_column(user::Column::Password) | ||
sea_query::OnConflict::column(Column::Email) | ||
.update_column(Column::FirstName) | ||
.update_column(Column::LastName) | ||
.update_column(Column::Password) | ||
.to_owned(), | ||
) | ||
.exec(db) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters