Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(oracle): generate compatible index drop SQL

zipge43fd9c50267
diff --git a/crates/dbx-core/src/schema_diff.rs b/crates/dbx-core/src/schema_diff.rs
index a5758837af..c4c103e8f8 100644
--- a/crates/dbx-core/src/schema_diff.rs
+++ b/crates/dbx-core/src/schema_diff.rs
@@ -3954,6 +3954,12 @@ fn drop_index_sql(table_name: &str, index_name: &str, db_type: DatabaseType, sch
return sqlserver_single_statement_batch(&batch);
}
let index = qualified_name(index_name, db_type, schema);
+ if matches!(db_type, DatabaseType::Oracle | DatabaseType::OceanbaseOracle) {
+ // Oracle versions before 23c do not support `DROP INDEX IF EXISTS`.
+ // Schema comparison already identified this index as present, so the
+ // direct form is both valid and sufficient for the generated script.
+ return format!("DROP INDEX {index};");
+ }
if profile.drop_index_uses_on_table {
format!("DROP INDEX {} ON {table};", quote_id(index_name, db_type))
} else {
@@ -6214,6 +6220,18 @@ mod tests {
}
}
+ #[test]
+ fn oracle_schema_sync_drops_indexes_without_if_exists() {
+ assert_eq!(
+ drop_index_sql("orders", "idx_orders_status", DatabaseType::Oracle, Some("APP")),
+ "DROP INDEX APP.IDX_ORDERS_STATUS;"
+ );
+ assert_eq!(
+ drop_index_sql("orders", "idx_orders_status", DatabaseType::OceanbaseOracle, Some("APP")),
+ "DROP INDEX APP.IDX_ORDERS_STATUS;"
+ );
+ }
+
#[test]
fn manual_table_mapping_compares_source_with_target_metadata_and_uses_target_ddl_name() {
let result = prepare_schema_diff(SchemaDiffPreparationOptions {