mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-04 18:40:47 +00:00
fix: missing files
This commit is contained in:
parent
7e9f63afe2
commit
db2e6197be
2 changed files with 65 additions and 0 deletions
19
entity/src/session.rs
Normal file
19
entity/src/session.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "session")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
pub hashed_token: String,
|
||||||
|
pub user_id: i32,
|
||||||
|
pub created_at: DateTime,
|
||||||
|
pub updated_at: DateTime,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
46
migration/src/m20221025_154422_create_session.rs
Normal file
46
migration/src/m20221025_154422_create_session.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
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::HashedToken).string().not_null())
|
||||||
|
.col(ColumnDef::new(Session::UserId).integer().not_null())
|
||||||
|
.col(ColumnDef::new(Session::CreatedAt).date_time().not_null())
|
||||||
|
.col(ColumnDef::new(Session::UpdatedAt).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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Learn more at https://docs.rs/sea-query#iden
|
||||||
|
#[derive(Iden)]
|
||||||
|
enum Session {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
HashedToken,
|
||||||
|
UserId,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue