mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
feat(database)!: switch from diesel to sea-orm
This commit is contained in:
6
database/entity/src/lib.rs
Normal file
6
database/entity/src/lib.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.12
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod sea_orm_active_enums;
|
||||
pub mod user;
|
||||
3
database/entity/src/prelude.rs
Normal file
3
database/entity/src/prelude.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.12
|
||||
|
||||
pub use super::user::Entity as User;
|
||||
25
database/entity/src/sea_orm_active_enums.rs
Normal file
25
database/entity/src/sea_orm_active_enums.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.12
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
EnumIter,
|
||||
DeriveActiveEnum,
|
||||
:: serde :: Serialize,
|
||||
:: serde :: Deserialize,
|
||||
:: utoipa :: ToSchema,
|
||||
)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "user_role")]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum UserRole {
|
||||
#[sea_orm(string_value = "student")]
|
||||
Student,
|
||||
#[sea_orm(string_value = "teacher")]
|
||||
Teacher,
|
||||
#[sea_orm(string_value = "admin")]
|
||||
Admin,
|
||||
}
|
||||
25
database/entity/src/user.rs
Normal file
25
database/entity/src/user.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.12
|
||||
|
||||
use super::sea_orm_active_enums::UserRole;
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "user")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: String,
|
||||
#[sea_orm(unique)]
|
||||
pub username: String,
|
||||
pub password: Option<String>,
|
||||
pub vk_id: Option<i32>,
|
||||
pub group: Option<String>,
|
||||
pub role: UserRole,
|
||||
pub android_version: Option<String>,
|
||||
#[sea_orm(unique)]
|
||||
pub telegram_id: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user