[ Agent ] [ App ] - mysql init
This commit is contained in:
@@ -42,9 +42,26 @@ func MysqlSqlFileLoad(jackeyLoveIp string, jackeyLoveFileList []string) (bool, [
|
||||
|
||||
// 逐行读取 SQL 文件并执行
|
||||
query := ""
|
||||
delimiterSwitched := false
|
||||
scanner := bufio.NewScanner(jackeyLove)
|
||||
for scanner.Scan() {
|
||||
sqlStatement := scanner.Text()
|
||||
|
||||
if strings.HasPrefix(strings.TrimSpace(sqlStatement), "DELIMITER") {
|
||||
delimiterSwitched = true
|
||||
continue
|
||||
}
|
||||
if delimiterSwitched {
|
||||
if strings.TrimSpace(sqlStatement) == "" || strings.TrimSpace(sqlStatement) == ";" {
|
||||
delimiterSwitched = false
|
||||
// 替换自定义分隔符为 ;
|
||||
sqlStatement = strings.ReplaceAll(sqlStatement, ";;", ";")
|
||||
} else {
|
||||
// 忽略自定义分隔符行
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// 这里可以添加逻辑来忽略空行或注释行
|
||||
if sqlStatement == "" || sqlStatement[:2] == "--" || sqlStatement[:2] == "/*" {
|
||||
continue
|
||||
|
||||
@@ -99,11 +99,11 @@ public class AppFuncScheduler {
|
||||
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
||||
// AppFunctionEnum.DEPLOY_RKE
|
||||
// AppFunctionEnum.DEPLOY_TEST_NFS
|
||||
AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
||||
AppFunctionEnum.DEPLOY_K8S_MYSQL
|
||||
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
||||
// AppFunctionEnum.DEPLOY_K8S_MYSQL
|
||||
// AppFunctionEnum.DEPLOY_K8S_REDIS
|
||||
// AppFunctionEnum.DEPLOY_K8S_PVC
|
||||
// AppFunctionEnum.LOAD_MYSQL_INIT_SCRIPT
|
||||
AppFunctionEnum.LOAD_MYSQL_INIT_SCRIPT
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user