neo/neo-migration/src/m20220707_092851_create_users.rs
Patrick Michl e33a734199
All checks were successful
continuous-integration/drone/push Build is passing
get back to where we were. but now with sea_orm and a more sane structure
2022-07-14 22:29:35 +02:00

51 lines
1.5 KiB
Rust

use neo_entity::users::{self, Entity as User};
use sea_orm_migration::prelude::*;
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220707_092851_create_users"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(User)
.if_not_exists()
.col(
ColumnDef::new(users::Column::Uuid)
.uuid()
.primary_key()
.not_null(),
)
.col(ColumnDef::new(users::Column::UserId).string().not_null())
.col(
ColumnDef::new(users::Column::DisplayName)
.string()
.not_null(),
)
.col(
ColumnDef::new(users::Column::PasswordHash)
.string()
.not_null(),
)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.name("user_id_index")
.table(User)
.col(users::Column::UserId)
.to_owned(),
)
.await
}
}