mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-25 21:11:50 +00:00
47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
pub struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(Session::Table)
|
|
.if_not_exists()
|
|
.col(
|
|
ColumnDef::new(Session::Id)
|
|
.uuid()
|
|
.not_null()
|
|
.unique_key()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(Session::UserId).integer())
|
|
.col(ColumnDef::new(Session::AdminId).integer())
|
|
.col(ColumnDef::new(Session::IpAddress).string().not_null())
|
|
.col(ColumnDef::new(Session::CreatedAt).date_time().not_null())
|
|
.col(ColumnDef::new(Session::ExpiresAt).date_time().not_null())
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Session::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(Iden)]
|
|
pub enum Session {
|
|
Table,
|
|
Id,
|
|
UserId,
|
|
AdminId,
|
|
IpAddress,
|
|
CreatedAt,
|
|
ExpiresAt,
|
|
}
|