go-gorm/gorm · error
not support
Error message
not support
What it means
GetIndexes on the base gorm.Migrator is a stub that returns errors.New("not support"). Each dialect driver (MySQL, Postgres, SQLite, SQLServer) is expected to override it; getting this error means the migrator in use did not provide an implementation, so index introspection is unavailable.
Source
Thrown at migrator/migrator.go:1032
}
for _, name := range orderedModelNames {
results = append(results, valuesMap[name].Statement.Dest)
}
return
}
// CurrentTable returns current statement's table expression
func (m Migrator) CurrentTable(stmt *gorm.Statement) interface{} {
if stmt.TableExpr != nil {
return *stmt.TableExpr
}
return clause.Table{Name: stmt.Table}
}
// GetIndexes return Indexes []gorm.Index and execErr error
func (m Migrator) GetIndexes(dst interface{}) ([]gorm.Index, error) {
return nil, errors.New("not support")
}
// GetTypeAliases return database type aliases
func (m Migrator) GetTypeAliases(databaseTypeName string) []string {
return nil
}
// TableType return tableType gorm.TableType and execErr error
func (m Migrator) TableType(dst interface{}) (gorm.TableType, error) {
return nil, errors.New("not support")
}
View on GitHub (pinned to 1d6ce99528)
Solutions
- Upgrade the dialect driver to a version that implements GetIndexes.
- Query the dialect's catalog directly (information_schema.statistics / pg_indexes / sqlite_master) with db.Raw.
- If you maintain the driver, implement GetIndexes on your Migrator.
- Feature-detect at startup so the tool degrades gracefully instead of failing per call.
Example fix
// before
idxs, err := db.Migrator().GetIndexes(&User{}) // err = "not support"
// after (dialect catalog query)
var rows []struct{ IndexName string }
db.Raw("SELECT indexname AS index_name FROM pg_indexes WHERE tablename = ?", "users").Scan(&rows) Defensive patterns
Strategy: fallback
Validate before calling
func supportsGetIndexes(m gorm.Migrator) bool {
_, err := m.GetIndexes(&probeModel{})
return err == nil || !strings.Contains(err.Error(), "not support")
} Try / catch
idxs, err := db.Migrator().GetIndexes(&User{})
if err != nil && strings.Contains(err.Error(), "not support") {
idxs, err = indexesFromCatalog(db, "users") // fallback raw SQL
}
if err != nil { return err } Prevention
- Feature-detect migrator capabilities once at startup and store the result.
- Pin driver versions known to implement the introspection APIs you use.
When it happens
Trigger: Calling db.Migrator().GetIndexes(&User{}) on a driver whose Migrator type does not override GetIndexes (niche/unmaintained drivers, or an old driver version predating the API), or calling it directly on the embedded base Migrator.
Common situations: Using a community driver (clickhouse, odps, luaxia/sqlite forks) that never implemented GetIndexes; upgrading GORM core to a version that added the API faster than the driver did; writing schema-diff tooling that assumes every dialect supports index introspection.
Related errors
- failed to get schema
- failed to unmarshal gob value: %#v
- violates check constraint
- unsupported relationship
- record not found
AI-assisted analysis of go-gorm/gorm@1d6ce99528 (2026-08-15).
Data as JSON: /api/errors/a83a1bbe33f45e8a.
Report an issue: GitHub.