save code

This commit is contained in:
白茶清欢 2022-05-15 21:29:39 +08:00
parent 9c1e726f19
commit b2dcef0553

View File

@ -35,3 +35,21 @@ func (sd *SystemDao) GetTableList(dbInstance *gorm.DB) ([]string, error) {
}
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
}