mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
feat(db): add service users table
This commit is contained in:
@@ -3,6 +3,7 @@ pub use sea_orm_migration::prelude::MigratorTrait;
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20250904_024854_init;
|
||||
mod m20251027_230335_add_service_users;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -11,6 +12,7 @@ impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![
|
||||
Box::new(m20250904_024854_init::Migration),
|
||||
Box::new(m20251027_230335_add_service_users::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
33
database/migration/src/m20251027_230335_add_service_users.rs
Normal file
33
database/migration/src/m20251027_230335_add_service_users.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
|
||||
#[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(ServiceUser::Table)
|
||||
.if_not_exists()
|
||||
.col(string_uniq(ServiceUser::Id).primary_key().not_null())
|
||||
.col(string(ServiceUser::Name))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(ServiceUser::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum ServiceUser {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
}
|
||||
Reference in New Issue
Block a user