feat: add setup_tokens entity and migration for SeaORM
This commit is contained in:
@@ -7,6 +7,7 @@ mod m20240301_000004_create_virtual_hosts;
|
||||
mod m20240301_000005_create_upstreams;
|
||||
mod m20240301_000006_create_certificates;
|
||||
mod m20240301_000007_create_users;
|
||||
mod m20240301_000008_create_setup_tokens;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -21,6 +22,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20240301_000005_create_upstreams::Migration),
|
||||
Box::new(m20240301_000006_create_certificates::Migration),
|
||||
Box::new(m20240301_000007_create_users::Migration),
|
||||
Box::new(m20240301_000008_create_setup_tokens::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
60
migration/src/m20240301_000008_create_setup_tokens.rs
Normal file
60
migration/src/m20240301_000008_create_setup_tokens.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
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(SetupTokens::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(SetupTokens::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(SetupTokens::TokenHash)
|
||||
.string()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(SetupTokens::ExpiresAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(SetupTokens::UsedAt)
|
||||
.timestamp_with_time_zone(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(SetupTokens::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(SetupTokens::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum SetupTokens {
|
||||
Table,
|
||||
Id,
|
||||
TokenHash,
|
||||
ExpiresAt,
|
||||
UsedAt,
|
||||
CreatedAt,
|
||||
}
|
||||
Reference in New Issue
Block a user