feat(migrator.go and migrator/migrator.go) : remove Table Struct replace with []string

This commit is contained in:
dino.ma 2021-11-09 20:09:19 +08:00
parent f676d504f3
commit acde65b965
2 changed files with 3 additions and 7 deletions

View File

@ -36,11 +36,6 @@ type ViewOption struct {
// ALLTables get all database tables
const ALLTables = "migrator:all_tables"
// Table Database table list info
type Table struct {
TableName string `gorm:"column:TABLE_NAME"`
}
type ColumnType interface {
Name() string
DatabaseTypeName() string
@ -62,7 +57,8 @@ type Migrator interface {
DropTable(dst ...interface{}) error
HasTable(dst interface{}) bool
RenameTable(oldName, newName interface{}) error
GetTables(tables ...string) (tableList []Table, err error)
GetTables(tables ...string) (tableList []string, err error)
// Columns
AddColumn(dst interface{}, field string) error
DropColumn(dst interface{}, field string) error

View File

@ -162,7 +162,7 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
return nil
}
func (m Migrator) GetTables(tables ...string) (tableList []gorm.Table, err error) {
func (m Migrator) GetTables(tables ...string) (tableList []string, err error) {
if len(tables) == 1 && tables[0] == gorm.ALLTables {
return tableList, m.DB.Raw(allTableQuery, m.CurrentDatabase()).Scan(&tableList).Error
}