save code
This commit is contained in:
parent
9c1e726f19
commit
b2dcef0553
18
system.go
18
system.go
@ -35,3 +35,21 @@ func (sd *SystemDao) GetTableList(dbInstance *gorm.DB) ([]string, error) {
|
|||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCreateTableSQL 获取建表SQL
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 20:58 2022/5/15
|
||||||
|
func (sd *SystemDao) GetCreateTableSQL(dbInstance *gorm.DB, table string) (string, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
result string
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = dbInstance.Raw("SHOW CREATE TABLE " + table).Scan(&result).Error; nil != err {
|
||||||
|
err = dbInstance.Exec("SHOW CREATE TABLE `" + table + "`;").Row().Scan(&result)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user