From 2f136fbb011537d8838727b92737d4f901254df1 Mon Sep 17 00:00:00 2001 From: Sphereso Date: Fri, 5 Jul 2024 16:08:59 +0200 Subject: [PATCH] backend: remove column salt from user --- crates/entity/src/user.rs | 57 ++----------------- .../src/m20240705_100914_create_user.rs | 2 - 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/crates/entity/src/user.rs b/crates/entity/src/user.rs index 5c896f4..653e299 100644 --- a/crates/entity/src/user.rs +++ b/crates/entity/src/user.rs @@ -2,65 +2,18 @@ use sea_orm::entity::prelude::*; -#[derive(Copy, Clone, Default, Debug, DeriveEntity)] -pub struct Entity; - -impl EntityName for Entity { - fn table_name(&self) -> &str { - "user" - } -} - -#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "user")] pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub name: String, + #[sea_orm(unique)] pub email: String, pub hash: String, - pub salt: String, } -#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] -pub enum Column { - Id, - Name, - Email, - Hash, - Salt, -} - -#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] -pub enum PrimaryKey { - Id, -} - -impl PrimaryKeyTrait for PrimaryKey { - type ValueType = Uuid; - fn auto_increment() -> bool { - false - } -} - -#[derive(Copy, Clone, Debug, EnumIter)] +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} -impl ColumnTrait for Column { - type EntityName = Entity; - fn def(&self) -> ColumnDef { - match self { - Self::Id => ColumnType::Uuid.def(), - Self::Name => ColumnType::String(None).def(), - Self::Email => ColumnType::String(None).def().unique(), - Self::Hash => ColumnType::String(None).def(), - Self::Salt => ColumnType::String(None).def(), - } - } -} - -impl RelationTrait for Relation { - fn def(&self) -> RelationDef { - panic!("No RelationDef") - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/migration/src/m20240705_100914_create_user.rs b/crates/migration/src/m20240705_100914_create_user.rs index a8c940f..2c8146c 100644 --- a/crates/migration/src/m20240705_100914_create_user.rs +++ b/crates/migration/src/m20240705_100914_create_user.rs @@ -21,7 +21,6 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(User::Name).string().not_null()) .col(ColumnDef::new(User::Email).string().not_null().unique_key()) .col(ColumnDef::new(User::Hash).string().not_null()) - .col(ColumnDef::new(User::Salt).string().not_null()) .to_owned(), ) .await @@ -41,5 +40,4 @@ enum User { Name, Email, Hash, - Salt, }