mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2026-10-28 09:44:56 +00:00
Widen MySQL art columns to TEXT
This commit is contained in:
1 parent
61f0282596
commit
0e3577da0d
2 files changed
+21
-1
No files matched your search
@@ -812,7 +812,7 @@ public class Database extends Queue {
|
||||
|
||||
// Art map
|
||||
index = ", INDEX(id)";
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,art varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,art TEXT" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||
|
||||
// Block
|
||||
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
|
||||
|
||||
@@ -376,11 +376,31 @@ public class __2_25_1 {
|
||||
statement.executeUpdate(alterQuery);
|
||||
}
|
||||
|
||||
private static void widenMySQLArt(Statement statement) throws SQLException {
|
||||
String table = ConfigHandler.prefix + "art_map";
|
||||
String type;
|
||||
try (ResultSet columns = statement.executeQuery("SHOW COLUMNS FROM " + table + " LIKE 'art'")) {
|
||||
if (!columns.next()) {
|
||||
throw new SQLException("Missing MySQL column " + table + ".art");
|
||||
}
|
||||
type = columns.getString("Type");
|
||||
}
|
||||
String normalizedType = type == null ? "" : type.toLowerCase(Locale.ROOT);
|
||||
if (normalizedType.equals("text") || normalizedType.equals("mediumtext") || normalizedType.equals("longtext")) {
|
||||
return;
|
||||
}
|
||||
if (!normalizedType.startsWith("varchar(") && !normalizedType.startsWith("char(") && !normalizedType.equals("tinytext")) {
|
||||
throw new SQLException("Unsupported MySQL " + table + ".art type: " + type);
|
||||
}
|
||||
statement.executeUpdate("ALTER TABLE " + table + " MODIFY art TEXT");
|
||||
}
|
||||
|
||||
protected static boolean patch(Statement statement) {
|
||||
try {
|
||||
if (Config.getGlobal().MYSQL) {
|
||||
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "sign MODIFY line_1 TEXT, MODIFY line_2 TEXT, MODIFY line_3 TEXT, MODIFY line_4 TEXT, MODIFY line_5 TEXT, MODIFY line_6 TEXT, MODIFY line_7 TEXT, MODIFY line_8 TEXT");
|
||||
widenMySQLBlockMetadata(statement);
|
||||
widenMySQLArt(statement);
|
||||
}
|
||||
addSignRollbackColumn(statement, Config.getGlobal().MYSQL ? DatabaseType.MYSQL : DatabaseType.SQLITE);
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user