Skip to content

Commit

Permalink
feat(migrator.go) : add GetTables method. (#71)
Browse files Browse the repository at this point in the history
* feat(migrator.go) : add GetTables method.

* fix(migrator.go): use CurrentSchema method
  • Loading branch information
dino-ma committed Nov 12, 2021
1 parent 6a0adf7 commit 0a62fb5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions migrator.go
Expand Up @@ -163,6 +163,11 @@ func (m Migrator) DropIndex(value interface{}, name string) error {
})
}

func (m Migrator) GetTables() (tableList []string, err error) {
currentSchema, _ := m.CurrentSchema(m.DB.Statement, "")
return tableList, m.DB.Raw("SELECT table_name FROM information_schema.tables WHERE table_schema = ? AND table_type = ?", currentSchema, "BASE TABLE").Scan(&tableList).Error
}

func (m Migrator) CreateTable(values ...interface{}) (err error) {
if err = m.Migrator.CreateTable(values...); err != nil {
return
Expand Down

0 comments on commit 0a62fb5

Please sign in to comment.