From e617ae689f9e6bc50a5f7839e2e17eeb0c2a6a00 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 4 Oct 2017 18:16:07 +0300 Subject: [PATCH] Fixes #329 --- .../com/djrapitops/plan/database/databases/SQLDB.java | 6 +++++- .../com/djrapitops/plan/database/tables/ServerTable.java | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index c44e50c9a..eb8d61e1b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -110,7 +110,7 @@ public abstract class SQLDB extends Database { if (newDatabase) { Log.info("New Database created."); - setVersion(10); + setVersion(11); } int version = getVersion(); @@ -128,6 +128,10 @@ public abstract class SQLDB extends Database { } }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); } + if (version < 11) { + serverTable.alterTableV11(); + setVersion(11); + } } catch (SQLException e) { throw new DatabaseInitException("Failed to set-up Database", e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java index 30fd3a236..5b5c69fad 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java @@ -65,12 +65,18 @@ public class ServerTable extends Table { .column(columnServerName, Sql.varchar(100)) .column(columnWebserverAddress, Sql.varchar(100)) .column(columnInstalled, Sql.BOOL).notNull().defaultValue(false) - .column(columnMaxPlayers, Sql.BOOL).notNull().defaultValue("-1") + .column(columnMaxPlayers, Sql.INT).notNull().defaultValue("-1") .primaryKey(usingMySQL, columnServerID) .toString() ); } + public void alterTableV11() { + if (usingMySQL) { + executeUnsafe("ALTER TABLE " + tableName + " MODIFY " + columnMaxPlayers + " INTEGER NOT NULL DEFAULT -1"); + } + } + public void saveCurrentServerInfo(ServerInfo info) throws SQLException { if (info.getId() == -1) { saveNewServerInfo(info);