Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add method GetIndexes #5436

Merged
merged 3 commits into from Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions migrator.go
Expand Up @@ -50,6 +50,14 @@ type ColumnType interface {
Comment() (value string, ok bool)
DefaultValue() (value string, ok bool)
}
type Index interface {
qqxhb marked this conversation as resolved.
Show resolved Hide resolved
Table() string
Name() string
Columns() []string
PrimaryKey() (isPrimaryKey bool, ok bool)
Unique() (unique bool, ok bool)
Option() string
}

// Migrator migrator interface
type Migrator interface {
Expand Down Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions migrator/migrator.go
Expand Up @@ -3,6 +3,7 @@ package migrator
import (
"context"
"database/sql"
"errors"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -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")
}