[Fix] Patch System column addition fixes

This affects KillsServerIDPatch and IPHashPatch issues.

Affected issues: #732
This commit is contained in:
Rsl1122 2018-09-26 20:40:41 +03:00
parent e72b89571e
commit 92ce37dda3
7 changed files with 8 additions and 11 deletions

View File

@ -16,7 +16,7 @@ public class GeoInfoLastUsedPatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(GeoInfoTable.TABLE_NAME, addColumn(GeoInfoTable.TABLE_NAME,
GeoInfoTable.Col.LAST_USED + " bigint NOT NULL DEFAULT 0" GeoInfoTable.Col.LAST_USED + " bigint NOT NULL DEFAULT 0"
); );
} }

View File

@ -16,6 +16,6 @@ public class IPHashPatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(GeoInfoTable.Col.IP_HASH.get() + " varchar(200) DEFAULT ''"); addColumn(GeoInfoTable.TABLE_NAME, GeoInfoTable.Col.IP_HASH.get() + " varchar(200) DEFAULT ''");
} }
} }

View File

@ -40,7 +40,7 @@ public class KillsServerIDPatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(KillsTable.Col.SERVER_ID + " integer NOT NULL DEFAULT 0"); addColumn(KillsTable.TABLE_NAME, KillsTable.Col.SERVER_ID + " integer NOT NULL DEFAULT 0");
Map<Integer, Integer> sessionIDServerIDRelation = db.getSessionsTable().getIDServerIDRelation(); Map<Integer, Integer> sessionIDServerIDRelation = db.getSessionsTable().getIDServerIDRelation();

View File

@ -25,7 +25,7 @@ public class NicknameLastSeenPatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(NicknamesTable.TABLE_NAME, addColumn(NicknamesTable.TABLE_NAME,
NicknamesTable.Col.LAST_USED + " bigint NOT NULL DEFAULT '0'" NicknamesTable.Col.LAST_USED + " bigint NOT NULL DEFAULT '0'"
); );

View File

@ -78,11 +78,8 @@ public abstract class Patch {
}); });
} }
protected void addColumns(String tableName, String... columnInfo) { protected void addColumn(String tableName, String columnInfo) {
for (int i = 0; i < columnInfo.length; i++) { db.executeUnsafe("ALTER TABLE " + tableName + " ADD " + (usingMySQL ? "" : "COLUMN ") + columnInfo);
columnInfo[i] = "ALTER TABLE " + tableName + " ADD " + (usingMySQL ? "" : "COLUMN ") + columnInfo[i];
}
db.executeUnsafe(columnInfo);
} }
protected void dropTable(String name) { protected void dropTable(String name) {

View File

@ -16,7 +16,7 @@ public class SessionAFKTimePatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(SessionsTable.TABLE_NAME, addColumn(SessionsTable.TABLE_NAME,
SessionsTable.Col.AFK_TIME + " bigint NOT NULL DEFAULT 0" SessionsTable.Col.AFK_TIME + " bigint NOT NULL DEFAULT 0"
); );
} }

View File

@ -16,6 +16,6 @@ public class TransferPartitionPatch extends Patch {
@Override @Override
public void apply() { public void apply() {
addColumns(TransferTable.TABLE_NAME, TransferTable.Col.PART + " bigint NOT NULL DEFAULT 0"); addColumn(TransferTable.TABLE_NAME, TransferTable.Col.PART + " bigint NOT NULL DEFAULT 0");
} }
} }