CreateToolConfigTable.java 1.3 KB

12345678910111213141516171819202122232425262728
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.Statement;
  4. public class CreateToolConfigTable {
  5. public static void main(String[] args) throws Exception {
  6. String db = args.length > 0 ? args[0] : "fs_tenant_cs1";
  7. String url = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/" + db
  8. + "?useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true";
  9. String sql = "CREATE TABLE IF NOT EXISTS lobster_tool_config ("
  10. + "id BIGINT AUTO_INCREMENT PRIMARY KEY,"
  11. + "company_id BIGINT NOT NULL DEFAULT 0,"
  12. + "tool_name VARCHAR(128) NOT NULL,"
  13. + "tool_type VARCHAR(64) DEFAULT NULL,"
  14. + "description VARCHAR(500) DEFAULT NULL,"
  15. + "config_json TEXT,"
  16. + "enabled TINYINT NOT NULL DEFAULT 1,"
  17. + "deleted TINYINT NOT NULL DEFAULT 0,"
  18. + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP,"
  19. + "UNIQUE KEY uk_company_tool (company_id, tool_name)"
  20. + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
  21. try (Connection c = DriverManager.getConnection(url, "root", "Ylrz_1q2w3e4r5t6y");
  22. Statement s = c.createStatement()) {
  23. s.execute(sql);
  24. System.out.println(db + " lobster_tool_config OK");
  25. }
  26. }
  27. }