From 98e73395fc30002e143e0f89faf191b7c7cd58f4 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:30:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20MariaDB=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#5605)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #5591 --- backend/app/service/database_mysql.go | 3 +++ backend/app/service/database_postgresql.go | 3 +++ backend/utils/mysql/client/local.go | 5 ++++- backend/utils/mysql/client/remote.go | 5 ++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index f1b3cbf76..07b39b50e 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -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 } diff --git a/backend/app/service/database_postgresql.go b/backend/app/service/database_postgresql.go index f8439e94c..07843447c 100644 --- a/backend/app/service/database_postgresql.go +++ b/backend/app/service/database_postgresql.go @@ -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 } diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go index 44a7693da..3110e3f06 100644 --- a/backend/utils/mysql/client/local.go +++ b/backend/utils/mysql/client/local.go @@ -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 diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go index 48a814e9e..9596ba9de 100644 --- a/backend/utils/mysql/client/remote.go +++ b/backend/utils/mysql/client/remote.go @@ -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