Skip to content

Commit

Permalink
feat: support db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-tastic-z committed May 30, 2024
1 parent 7993b84 commit d2c3433
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use lazy_static::lazy_static;
use migration::MigratorTrait;
use sea_orm::DatabaseConnection;
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::{task::JoinSet, time};
Expand Down Expand Up @@ -179,6 +180,11 @@ impl WatchVulnApp {
}
is_push
}

pub async fn run_migration(&self) -> Result<()> {
migration::Migrator::up(&self.app_context.db, None).await?;
Ok(())
}
}

#[derive(Clone)]
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async fn main() -> Result<()> {
let app_context = Arc::new(create_context(&environment).await?);
logger::init(&app_context.config.logger);
let app = WatchVulnApp::new(app_context);
app.run_migration().await?;
app.run().await?;
Ok(())
}

0 comments on commit d2c3433

Please sign in to comment.