chore: defer sea_orm migration after legacy migration done (#5358)

This pr propose to defer recently added and soon-to-be-added migrations
to be executed after the version-based migration is done with the meta
table.
This commit is contained in:
Taiming Liu
2024-12-15 19:13:54 -08:00
committed by GitHub
parent 706991dbd2
commit 45419b5700
3 changed files with 18 additions and 5 deletions
+4
View File
@@ -31,6 +31,10 @@ pub mod short_urls;
pub async fn init() -> Result<(), anyhow::Error> {
distinct_values::init().await?;
short_urls::init().await?;
Ok(())
}
pub async fn migrate() -> Result<(), anyhow::Error> {
let client = ORM_CLIENT.get_or_init(connect_to_orm).await;
Migrator::up(client, None).await?;
Ok(())
+12 -5
View File
@@ -221,17 +221,24 @@ async fn main() -> Result<(), anyhow::Error> {
job_init_tx.send(false).ok();
panic!("check upgrade failed: {}", e);
}
// migrate dashboards
if let Err(e) = migration::dashboards::run().await {
job_init_tx.send(false).ok();
panic!("migrate dashboards failed: {}", e);
}
#[allow(deprecated)]
migration::upgrade_resource_names()
.await
.expect("migrate resource names into supported ofga format failed");
// migrate infra_sea_orm
if let Err(e) = infra::table::migrate().await {
job_init_tx.send(false).ok();
panic!("infra sea_orm migrate failed: {}", e);
}
// migrate dashboards
if let Err(e) = migration::dashboards::run().await {
job_init_tx.send(false).ok();
panic!("migrate dashboards failed: {}", e);
}
// ingester init
if let Err(e) = ingester::init().await {
job_init_tx.send(false).ok();
+2
View File
@@ -127,6 +127,8 @@ mod tests {
config::init().await.unwrap();
// init infra
infra::init().await.unwrap();
// db migration steps, since it's separated out
infra::table::migrate().await.unwrap();
openobserve::common::infra::init().await.unwrap();
// ingester init
ingester::init().await.unwrap();