feat: NEZ-2203 21.07 -> 22.02 版本升级数据处理
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package net.geedge.handler;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import net.geedge.dao.SqlDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 此类用于数据同步完成后 清除无用表
|
||||
@@ -20,17 +21,28 @@ public class AfterHandler implements CommandLineRunner {
|
||||
private Log log = Log.get();
|
||||
|
||||
@Autowired
|
||||
private SqlHandler sqlHandler;
|
||||
|
||||
private SqlDao sqlDao;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
sqlHandler.removeColumn();
|
||||
String dropColumnSql = "ALTER TABLE `monitor_module` DROP COLUMN `type`;"
|
||||
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `configs`;"
|
||||
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `hash`;"
|
||||
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `enabled`;";
|
||||
sqlDao.execute(dropColumnSql);
|
||||
log.info("remove column successful");
|
||||
sqlHandler.removeCopy();
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<String> sqls = sqlDao.allRemoveCopyTables();
|
||||
for (String sql : sqls) {
|
||||
sb.append(sql);
|
||||
}
|
||||
sqlDao.execute(sb.toString());
|
||||
log.info("remove table successful");
|
||||
log.info("-----------------transfer data success-----------------------");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user