This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nz-transfer/src/main/java/net/geedge/handler/AfterHandler.java

49 lines
1.2 KiB
Java
Raw Normal View History

package net.geedge.handler;
2021-05-08 19:33:06 +08:00
import cn.hutool.log.Log;
import net.geedge.dao.SqlDao;
2021-05-08 19:33:06 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
2021-05-08 19:33:06 +08:00
/**
* 此类用于数据同步完成后 清除无用表
* @author admin
*
*/
@Component
@Order(3)
public class AfterHandler implements CommandLineRunner {
private Log log = Log.get();
@Autowired
private SqlDao sqlDao;
2021-05-08 19:33:06 +08:00
@Override
public void run(String... args) throws Exception {
2021-05-12 15:56:47 +08:00
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");
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");
2021-05-08 19:33:06 +08:00
log.info("-----------------transfer data success-----------------------");
2021-05-08 19:33:06 +08:00
}
}