| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import java.nio.charset.StandardCharsets;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- /** Apply V20260729: menu_id=29933 锟解户锟斤拷锟斤拷丶锟斤拷锟?锟斤拷 锟斤拷锟斤拷丶锟斤拷锟?*/
- public class ApplyLobsterSemanticMenuRename {
- private static final String HOST = "cq-cdb-8fjmemkb.sql.tencentcdb.com:27220";
- private static final String USER = "root";
- private static final String PASS = "Ylrz_1q2w3e4r5t6y";
- public static void main(String[] args) throws Exception {
- Class.forName("com.mysql.cj.jdbc.Driver");
- String tenantDb = args.length > 0 ? args[0] : "fs_tenant_cs1";
- String tenantSql = read("d:/ylrz_saas_new/java/fs-agent/src/main/resources/db/migration/tenant/V20260729_01__lobster_semantic_menu_rename.sql");
- String masterSql = read("d:/ylrz_saas_new/java/fs-agent/src/main/resources/db/migration/master/V20260729_01__lobster_semantic_menu_rename_master.sql");
- System.out.println("=== MASTER ylrz_saas ===");
- try (Connection c = open("ylrz_saas")) {
- exec(c, masterSql);
- show(c, "tenant_sys_menu");
- }
- System.out.println("\n=== TENANT " + tenantDb + " ===");
- try (Connection c = open(tenantDb)) {
- exec(c, tenantSql);
- show(c, "sys_menu");
- }
- System.out.println("\nDone.");
- }
- private static String read(String path) throws Exception {
- byte[] bytes = Files.readAllBytes(Path.of(path));
- String s = new String(bytes, StandardCharsets.UTF_8);
- return s.startsWith("\uFEFF") ? s.substring(1) : s;
- }
- private static void exec(Connection c, String sql) throws Exception {
- try (Statement st = c.createStatement()) {
- st.execute(sql);
- }
- }
- private static void show(Connection c, String table) throws Exception {
- String sql = "SELECT menu_id, menu_name, HEX(menu_name) hx FROM " + table + " WHERE menu_id = 29933";
- try (Statement st = c.createStatement(); ResultSet rs = st.executeQuery(sql)) {
- if (rs.next()) {
- System.out.println(rs.getLong(1) + " | " + rs.getString(2) + " | hx=" + rs.getString(3));
- } else {
- System.out.println("menu_id=29933 not found in " + table);
- }
- }
- }
- private static Connection open(String db) throws Exception {
- return DriverManager.getConnection(
- "jdbc:mysql://" + HOST + "/" + db + "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&allowMultiQueries=true",
- USER, PASS);
- }
- }
|