Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(walk-through): check if exists for drop index for pg (#13719)

rebelice40188839f226
diff --git a/backend/plugin/advisor/catalog/test/pg_walk_through.yaml b/backend/plugin/advisor/catalog/test/pg_walk_through.yaml
index c421565efa..c761eb0959 100644
--- a/backend/plugin/advisor/catalog/test/pg_walk_through.yaml
+++ b/backend/plugin/advisor/catalog/test/pg_walk_through.yaml
@@ -49,6 +49,7 @@
CREATE TABLE public.t(a int, "B" int);
CREATE INDEX ON t(a, "B");
CREATE UNIQUE INDEX ON t(a, "B");
+ DROP INDEX IF EXISTS t_a_B_idx_11111;
ignore_case_sensitive: false
want: |-
{
diff --git a/backend/plugin/advisor/catalog/walk_through_for_pg.go b/backend/plugin/advisor/catalog/walk_through_for_pg.go
index 9e184cc1e4..fcadc827b3 100644
--- a/backend/plugin/advisor/catalog/walk_through_for_pg.go
+++ b/backend/plugin/advisor/catalog/walk_through_for_pg.go
@@ -92,6 +92,9 @@ func (d *DatabaseState) pgDropIndex(indexDef *ast.IndexDef, ifExists bool, _ ast
table, index, err := schema.getIndex(indexDef.Name)
if err != nil {
+ if ifExists {
+ return nil
+ }
return err
}