feat: add method GetIndexes

This commit is contained in:
qqxhb 2022-06-16 19:36:14 +08:00
parent 8d45714628
commit 076e9777ee
2 changed files with 15 additions and 0 deletions

View File

@ -50,6 +50,14 @@ type ColumnType interface {
Comment() (value string, ok bool) Comment() (value string, ok bool)
DefaultValue() (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 // Migrator migrator interface
type Migrator interface { type Migrator interface {
@ -90,4 +98,5 @@ type Migrator interface {
DropIndex(dst interface{}, name string) error DropIndex(dst interface{}, name string) error
HasIndex(dst interface{}, name string) bool HasIndex(dst interface{}, name string) bool
RenameIndex(dst interface{}, oldName, newName string) error RenameIndex(dst interface{}, oldName, newName string) error
GetIndexes(dst interface{}) ([]Index, error)
} }

View File

@ -3,6 +3,7 @@ package migrator
import ( import (
"context" "context"
"database/sql" "database/sql"
"errors"
"fmt" "fmt"
"reflect" "reflect"
"regexp" "regexp"
@ -854,3 +855,8 @@ func (m Migrator) CurrentTable(stmt *gorm.Statement) interface{} {
} }
return clause.Table{Name: stmt.Table} 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")
}