diff --git a/migrator.go b/migrator.go index 52443877..39c4871b 100644 --- a/migrator.go +++ b/migrator.go @@ -50,6 +50,14 @@ type ColumnType interface { Comment() (value string, ok bool) DefaultValue() (value string, ok bool) } +type Index interface { + Table() string + Name() string + Columns() []string + PrimaryKey() (isPrimaryKey bool, ok bool) + Unique() (unique bool, ok bool) + Option() string +} // Migrator migrator interface type Migrator interface { @@ -90,4 +98,5 @@ type Migrator interface { DropIndex(dst interface{}, name string) error HasIndex(dst interface{}, name string) bool RenameIndex(dst interface{}, oldName, newName string) error + GetIndexes(dst interface{}) ([]Index, error) } diff --git a/migrator/migrator.go b/migrator/migrator.go index 4acc9df6..f20bf513 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -3,6 +3,7 @@ package migrator import ( "context" "database/sql" + "errors" "fmt" "reflect" "regexp" @@ -854,3 +855,8 @@ func (m Migrator) CurrentTable(stmt *gorm.Statement) interface{} { } 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") +}