Update migrator.go

This commit is contained in:
Jinzhu 2021-11-11 14:59:16 +08:00 committed by GitHub
parent 587707bba0
commit 87830a80ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,11 +18,6 @@ var (
regFullDataType = regexp.MustCompile(`[^\d]*(\d+)[^\d]?`) regFullDataType = regexp.MustCompile(`[^\d]*(\d+)[^\d]?`)
) )
const (
// allTableQuery query db table list
allTableQuery = "SELECT TABLE_NAME FROM information_schema.tables where TABLE_SCHEMA=?"
)
// Migrator m struct // Migrator m struct
type Migrator struct { type Migrator struct {
Config Config
@ -161,7 +156,8 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
} }
func (m Migrator) GetTables() (tableList []string, err error) { func (m Migrator) GetTables() (tableList []string, err error) {
return tableList, m.DB.Raw(allTableQuery, m.CurrentDatabase()).Scan(&tableList).Error sql := "SELECT TABLE_NAME FROM information_schema.tables where TABLE_SCHEMA=?"
return tableList, m.DB.Raw(sql, m.CurrentDatabase()).Scan(&tableList).Error
} }
func (m Migrator) CreateTable(values ...interface{}) error { func (m Migrator) CreateTable(values ...interface{}) error {