From acde65b965cb4f51a3dbab0684f7375678f2d5bf Mon Sep 17 00:00:00 2001 From: "dino.ma" Date: Tue, 9 Nov 2021 20:09:19 +0800 Subject: [PATCH] feat(migrator.go and migrator/migrator.go) : remove Table Struct replace with []string --- migrator.go | 8 ++------ migrator/migrator.go | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/migrator.go b/migrator.go index 6e95ad71..8bd4d1cf 100644 --- a/migrator.go +++ b/migrator.go @@ -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 diff --git a/migrator/migrator.go b/migrator/migrator.go index 2ec220cf..0a5030aa 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -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 }