diff --git a/public/database/src/generated/entities/mod.rs b/public/database/src/generated/entities/mod.rs index 72511ee..1917343 100644 --- a/public/database/src/generated/entities/mod.rs +++ b/public/database/src/generated/entities/mod.rs @@ -3,6 +3,5 @@ pub mod prelude; pub mod config; -pub mod session; pub mod user; pub mod user_identity; diff --git a/public/database/src/generated/entities/prelude.rs b/public/database/src/generated/entities/prelude.rs index e73b8a2..f0df089 100644 --- a/public/database/src/generated/entities/prelude.rs +++ b/public/database/src/generated/entities/prelude.rs @@ -1,6 +1,5 @@ //! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18 pub use super::config::Entity as Config; -pub use super::session::Entity as Session; pub use super::user::Entity as User; pub use super::user_identity::Entity as UserIdentity; diff --git a/public/database/src/generated/entities/user.rs b/public/database/src/generated/entities/user.rs index 4c01244..ab2edb2 100644 --- a/public/database/src/generated/entities/user.rs +++ b/public/database/src/generated/entities/user.rs @@ -18,8 +18,6 @@ pub struct Model { pub last_login_at: Option, pub deleted_at: Option, #[sea_orm(has_many)] - pub sessions: HasMany, - #[sea_orm(has_many)] pub user_identities: HasMany, } diff --git a/public/migration/src/lib.rs b/public/migration/src/lib.rs index eecb57c..83e0779 100644 --- a/public/migration/src/lib.rs +++ b/public/migration/src/lib.rs @@ -13,7 +13,6 @@ impl MigratorTrait for Migrator { Box::new(m20251011_000001_create_config_table::Migration), Box::new(m20251011_000002_create_user_table::Migration), Box::new(m20251011_000003_create_user_identity_table::Migration), - Box::new(m20251011_000004_create_session_table::Migration), ] } } diff --git a/public/migration/src/migrations.rs b/public/migration/src/migrations.rs index 5ff5d97..2ff1c48 100644 --- a/public/migration/src/migrations.rs +++ b/public/migration/src/migrations.rs @@ -1,4 +1,3 @@ pub mod m20251011_000001_create_config_table; pub mod m20251011_000002_create_user_table; pub mod m20251011_000003_create_user_identity_table; -pub mod m20251011_000004_create_session_table; diff --git a/public/migration/src/migrations/m20251011_000004_create_session_table.rs b/public/migration/src/migrations/m20251011_000004_create_session_table.rs deleted file mode 100644 index c7ab7f1..0000000 --- a/public/migration/src/migrations/m20251011_000004_create_session_table.rs +++ /dev/null @@ -1,86 +0,0 @@ -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[forbid(dead_code)] -#[derive(DeriveIden)] -pub enum Session { - Table, - Id, - UserId, - // - RefreshTokenHash, - // - ExpiresAt, - RevokedAt, - // - CreatedAt, - UpdatedAt, -} - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - let _ = manager - .create_table( - Table::create() - .table(Session::Table) - .if_not_exists() - .col(pk_uuid(Session::Id)) - // - .col(ColumnDef::new(Session::UserId).uuid().not_null()) - .foreign_key( - ForeignKey::create() - .name("fk-session-user-id") - .from(Session::Table, Session::UserId) - .to( - super::m20251011_000002_create_user_table::User::Table, - super::m20251011_000002_create_user_table::User::Id, - ) - .on_delete(ForeignKeyAction::Cascade) - .on_update(ForeignKeyAction::Cascade), - ) - .col( - ColumnDef::new(Session::RefreshTokenHash) - .string() - .null() - .unique_key(), - ) - .col(ColumnDef::new(Session::ExpiresAt).timestamp().not_null()) - .col(ColumnDef::new(Session::RevokedAt).timestamp().null()) - // - .col( - ColumnDef::new(Session::CreatedAt) - .timestamp() - .default(SimpleExpr::Keyword(Keyword::CurrentTimestamp)) - .not_null(), - ) - .col( - ColumnDef::new(Session::UpdatedAt) - .timestamp() - .default(SimpleExpr::Keyword(Keyword::CurrentTimestamp)) - .not_null(), - ) - .to_owned(), - ) - .await; - - manager - .create_index( - Index::create() - .name("idx-session-user-id-token") - .table(Session::Table) - .col(Session::UserId) - .col(Session::RefreshTokenHash) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Session::Table).to_owned()) - .await - } -}