remove unused session table

This commit is contained in:
GW_MC
2025-12-15 14:20:28 +08:00
parent 9447b64a76
commit b17d111c5d
6 changed files with 0 additions and 92 deletions

View File

@@ -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),
]
}
}

View File

@@ -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;

View File

@@ -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
}
}