AE86 2 jaren geleden
bovenliggende
commit
43fd7e94a2

+ 1 - 1
dbsyncer-connector/src/main/java/org/dbsyncer/connector/es/ESConnector.java

@@ -87,7 +87,7 @@ public final class ESConnector extends AbstractConnector implements Connector<ES
 
     @Override
     public String getConnectorMapperCacheKey(ESConfig config) {
-        return String.format("%s-%s-%s-%s-%s", config.getConnectorType(), config.getUrl(), config.getIndex(), config.getType(), config.getUsername());
+        return String.format("%s-%s-%s-%", config.getConnectorType(), config.getUrl(), config.getIndex(), config.getUsername());
     }
 
     @Override

+ 17 - 11
dbsyncer-storage/src/main/java/org/dbsyncer/storage/support/MysqlStorageServiceImpl.java

@@ -273,20 +273,26 @@ public class MysqlStorageServiceImpl extends AbstractStorageService {
     private void initUpgradeSql() {
         // show tables where Tables_in_dbsyncer like "dbsyncer_data%"
         String sql = String.format(SHOW_DATA_TABLE, database, PREFIX_TABLE.concat(StorageEnum.DATA.getType()).concat("%"));
-        Map<String, String> tables = null;
+        List<String> tables = null;
         try {
-            tables = connectorMapper.execute(databaseTemplate -> databaseTemplate.queryForMap(sql));
+            tables = connectorMapper.execute(databaseTemplate -> databaseTemplate.queryForList(sql, String.class));
         } catch (EmptyResultDataAccessException e) {
             // 没有可更新的表
         }
         if (CollectionUtils.isEmpty(tables)) {
             return;
         }
-        tables.values().forEach(table -> {
+        final String queryColumnCount = "SELECT count(*) FROM information_schema.columns WHERE table_name = '%s' and column_name = 'TABLE_GROUP_ID'";
+        tables.forEach(table -> {
             try {
-                String ddl = readSql(UPGRADE_SQL, true, table);
-                executeSql(ddl);
-                logger.info(ddl);
+                String query = String.format(queryColumnCount, table);
+                // 是否已升级
+                int count = connectorMapper.execute(databaseTemplate -> databaseTemplate.queryForObject(query, Integer.class));
+                if (count == 0) {
+                    String ddl = readSql(UPGRADE_SQL, true, table);
+                    executeSql(ddl);
+                    logger.info(ddl);
+                }
             } catch (Exception e) {
                 if (e.getCause() instanceof SQLSyntaxErrorException) {
                     SQLSyntaxErrorException ex = (SQLSyntaxErrorException) e.getCause();
@@ -404,11 +410,11 @@ public class MysqlStorageServiceImpl extends AbstractStorageService {
         if (!CollectionUtils.isEmpty(list) && query.isEnableHighLightSearch()) {
             List<Param> highLight = query.getParams().stream().filter(p -> p.isHighlighter()).collect(Collectors.toList());
             list.forEach(row ->
-                highLight.forEach(p -> {
-                    String text = String.valueOf(row.get(p.getKey()));
-                    String replacement = new StringBuilder("<span style='color:red'>").append(p.getValue()).append("</span>").toString();
-                    row.put(p.getKey(), StringUtil.replace(text, p.getValue(), replacement));
-                })
+                    highLight.forEach(p -> {
+                        String text = String.valueOf(row.get(p.getKey()));
+                        String replacement = new StringBuilder("<span style='color:red'>").append(p.getValue()).append("</span>").toString();
+                        row.put(p.getKey(), StringUtil.replace(text, p.getValue(), replacement));
+                    })
             );
         }
     }

+ 1 - 1
dbsyncer-web/src/main/resources/public/index/index.html

@@ -72,8 +72,8 @@
                                         <div class="dropdown">
                                             <a data-toggle="dropdown" href="javascript:;"><span class="well-sign-operation"><i class="fa fa-gears fa-1x"></i></span></a>
                                             <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
-                                                <li class="remove" th:url="'/connector/remove?id='+${c?.id}"><a href="javascript:;"><i class="fa fa-trash well-sign-red"></i>&nbsp;&nbsp;删除</a></li>
                                                 <li class="copy" th:url="'/connector/copy?id='+${c?.id}"><a href="javascript:;"><i class="fa fa-copy"></i>&nbsp;复制</a></li>
+                                                <li class="remove" th:url="'/connector/remove?id='+${c?.id}"><a href="javascript:;"><i class="fa fa-trash well-sign-red"></i> 删除</a></li>
                                             </ul>
                                         </div>
                                     </div>