Skip to content

fix(Migrator): add schema qualification to GetIndexes, RenameIndex, DropIndex#340

Merged
jinzhu merged 1 commit into
go-gorm:masterfrom
lihan3238:fix-226-schema-qualification
May 11, 2026
Merged

fix(Migrator): add schema qualification to GetIndexes, RenameIndex, DropIndex#340
jinzhu merged 1 commit into
go-gorm:masterfrom
lihan3238:fix-226-schema-qualification

Conversation

@lihan3238
Copy link
Copy Markdown
Contributor

Closes #226

Problem

GetIndexes, RenameIndex, and DropIndex do not use CurrentSchema to qualify index operations. This causes incorrect results when tables reside in non-default PostgreSQL schemas.

By contrast, HasIndex, HasTable, HasColumn, and HasConstraint all call CurrentSchema/CurrentTable to filter by schema.

Changes

  • GetIndexes: Call CurrentSchema and add schema filter to the indexSql query
  • RenameIndex: Schema-qualify the ALTER INDEX target using CurrentSchema
  • DropIndex: Schema-qualify the DROP INDEX target using CurrentSchema

All three follow the same pattern already used by HasIndex and other methods in this file.

…ropIndex

GetIndexes, RenameIndex, and DropIndex did not use CurrentSchema to
qualify index operations, causing incorrect results when tables reside in
non-default schemas. This aligns them with HasIndex, HasTable, and
HasColumn which already call CurrentSchema.

Closes go-gorm#226
@jinzhu jinzhu merged commit 4d6a58d into go-gorm:master May 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index functions (GetIndexes, DropIndex, RenameIndex) doesn't use current table schema

2 participants