Pull in code from pool_elo
need to re-integrate yugioh code
This commit is contained in:
12
migration/src/lib.rs
Normal file
12
migration/src/lib.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
pub use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20240813_000001_create_users;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(m20240813_000001_create_users::Migration)]
|
||||
}
|
||||
}
|
||||
52
migration/src/m20240813_000001_create_users.rs
Normal file
52
migration/src/m20240813_000001_create_users.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
// https://github.com/SeaQL/sea-orm/blob/368b1126f73f47c7ec30fe523834f6a0962a193b/sea-orm-migration/src/schema.rs
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
// User table
|
||||
// @todo verify all data saved is length-checked
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(User::Table)
|
||||
.col(pk_auto(User::Id))
|
||||
.col(string_uniq(User::Username))
|
||||
.col(string(User::PasswordHashAndSalt))
|
||||
.col(string_null(User::Nickname))
|
||||
.col(timestamp(User::CreationTime))
|
||||
.col(timestamp(User::LastActiveTime))
|
||||
.col(boolean(User::IsAdmin))
|
||||
.col(string_null(User::Email))
|
||||
.col(string_null(User::Avatar))
|
||||
.col(string_null(User::ForgotPasswordRequest))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(User::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
pub enum User {
|
||||
Table,
|
||||
Id,
|
||||
Username,
|
||||
PasswordHashAndSalt,
|
||||
Nickname,
|
||||
CreationTime,
|
||||
LastActiveTime,
|
||||
IsAdmin,
|
||||
Email,
|
||||
Avatar,
|
||||
ForgotPasswordRequest,
|
||||
}
|
||||
6
migration/src/main.rs
Normal file
6
migration/src/main.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
cli::run_cli(migration::Migrator).await;
|
||||
}
|
||||
Reference in New Issue
Block a user