mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-23 16:41:57 +00:00
commit
ef594e8227
5 changed files with 69 additions and 0 deletions
|
|
@ -3,3 +3,4 @@ pub mod prelude;
|
|||
pub mod admin;
|
||||
pub mod candidate;
|
||||
pub mod parent;
|
||||
pub mod session;
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@
|
|||
pub use super::admin::Entity as Admin;
|
||||
pub use super::candidate::Entity as Candidate;
|
||||
pub use super::parent::Entity as Parent;
|
||||
pub use super::session::Entity as Session;
|
||||
|
|
|
|||
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 {}
|
||||
|
|
@ -4,6 +4,7 @@ mod m20221024_111310_create_admin;
|
|||
mod m20221024_121621_create_candidate;
|
||||
mod m20221024_124701_create_parent;
|
||||
mod m20221024_134454_fill_admin;
|
||||
mod m20221025_154422_create_session;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20221024_121621_create_candidate::Migration),
|
||||
Box::new(m20221024_124701_create_parent::Migration),
|
||||
Box::new(m20221024_134454_fill_admin::Migration::default()),
|
||||
Box::new(m20221025_154422_create_session::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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