fix: 解决 MariaDB 数据库同步失败的问题 (#5605)

Refs #5591
This commit is contained in:
ssongliu 2024-06-28 15:30:59 +08:00 committed by GitHub
parent 65fb2bd401
commit 98e73395fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View File

@ -196,6 +196,9 @@ func (u *MysqlService) LoadFromRemote(req dto.MysqlLoadDB) error {
for i := 0; i < len(databases); i++ {
if strings.EqualFold(databases[i].Name, data.Name) && strings.EqualFold(databases[i].MysqlName, data.MysqlName) {
hasOld = true
if databases[i].IsDelete {
_ = mysqlRepo.Update(databases[i].ID, map[string]interface{}{"is_delete": false})
}
deleteList = append(deleteList[:i], deleteList[i+1:]...)
break
}

View File

@ -222,6 +222,9 @@ func (u *PostgresqlService) LoadFromRemote(database string) error {
for i := 0; i < len(databases); i++ {
if strings.EqualFold(databases[i].Name, data.Name) && strings.EqualFold(databases[i].PostgresqlName, data.PostgresqlName) {
hasOld = true
if databases[i].IsDelete {
_ = postgresqlRepo.Update(databases[i].ID, map[string]interface{}{"is_delete": false})
}
deleteList = append(deleteList[:i], deleteList[i+1:]...)
break
}

View File

@ -300,7 +300,10 @@ func (r *Local) SyncDB(version string) ([]SyncDBInfo, error) {
}
userLines, err := r.ExecSQLForRows(fmt.Sprintf("select user,host from mysql.db where db = '%s'", parts[0]), 300)
if err != nil {
return datas, err
global.LOG.Debugf("sync user of db %s failed, err: %v", parts[0], err)
dataItem.Permission = "%"
datas = append(datas, dataItem)
continue
}
var permissionItem []string

View File

@ -332,7 +332,10 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) {
}
userRows, err := r.Client.Query("select user,host from mysql.db where db = ?", dbName)
if err != nil {
return datas, err
global.LOG.Debugf("sync user of db %s failed, err: %v", dbName, err)
dataItem.Permission = "%"
datas = append(datas, dataItem)
continue
}
var permissionItem []string