mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 08:09:22 +00:00
fix: broken MySQL migration for dropping index (#5436)
The migration to drop an index on the `folders` table fails for MySQL.
The `DROP INDEX` statement in MySQL requires specifying the table name
but including the table name is not allowed for PostgreSQL and Sqlite.
⚠️ **Migration change:** This PR modifies an existing migration, so we
should be very careful not to alter the behavior of a migration that has
already been applied to users' databases. In this case, this PR only
changes the behavior of the `aler_folder_table_idx` migration when the
database backend is MySQL. Prior to this PR that migration would panic
when ran on a MySQL database, so no user with a MySQL database will have
been able to successfully run this migration yet. Therefore there should
be not risk of creating diverging migration behavior in this PR.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Chores**
- Updated migration logic for the `folders` table to enhance indexing
clarity.
- Improved index drop operations for the dashboards, alerts, and search
queue tables by specifying the associated tables.
- Introduced a new CLI command `seaorm-rollback` for rolling back
migration steps, with options to rollback all or the last N migrations.
- Added an asynchronous function to facilitate migration rollbacks with
optional step specification.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -117,6 +117,16 @@ pub async fn cli() -> Result<bool, anyhow::Error> {
|
||||
.help("the parquet file name"),
|
||||
),
|
||||
clap::Command::new("migrate-schemas").about("migrate from single row to row per schema version"),
|
||||
clap::Command::new("seaorm-rollback").about("rollback SeaORM migration steps")
|
||||
.subcommand(
|
||||
clap::Command::new("all")
|
||||
.about("rollback all SeaORM migration steps")
|
||||
)
|
||||
.subcommand(
|
||||
clap::Command::new("last")
|
||||
.about("rollback last N SeaORM migration steps")
|
||||
.arg(clap::Arg::new("N").help("number of migration steps to rollback (default is 1)").value_parser(clap::value_parser!(u32)))
|
||||
),
|
||||
])
|
||||
.get_matches();
|
||||
|
||||
@@ -274,6 +284,26 @@ pub async fn cli() -> Result<bool, anyhow::Error> {
|
||||
#[allow(deprecated)]
|
||||
migration::schema::run().await?
|
||||
}
|
||||
"seaorm-rollback" => match command.subcommand() {
|
||||
Some(("all", _)) => {
|
||||
println!("Rolling back all");
|
||||
infra::table::down(None).await?
|
||||
}
|
||||
Some(("last", sub_matches)) => {
|
||||
let n = sub_matches
|
||||
.get_one::<u32>("N")
|
||||
.map(|n| n.to_owned())
|
||||
.unwrap_or(1);
|
||||
println!("Rolling back {n}");
|
||||
infra::table::down(Some(n)).await?
|
||||
}
|
||||
Some((name, _)) => {
|
||||
return Err(anyhow::anyhow!("unsupported sub command: {name}"));
|
||||
}
|
||||
None => {
|
||||
return Err(anyhow::anyhow!("missing sub command"));
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!("unsupported sub command: {name}"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user