Fixes #355 on existing MySQL databases

This commit is contained in:
Rsl1122 2017-10-24 11:43:40 +03:00
parent 889b2ac045
commit e7fbee7991
2 changed files with 11 additions and 1 deletions

View File

@ -109,7 +109,7 @@ public abstract class SQLDB extends Database {
if (newDatabase) {
Log.info("New Database created.");
setVersion(11);
setVersion(12);
}
int version = getVersion();
@ -131,6 +131,10 @@ public abstract class SQLDB extends Database {
serverTable.alterTableV11();
setVersion(11);
}
if (version < 12) {
ipsTable.alterTableV12();
setVersion(12);
}
} catch (SQLException e) {
throw new DatabaseInitException("Failed to set-up Database", e);
}

View File

@ -50,6 +50,12 @@ public class IPsTable extends UserIDTable {
);
}
public void alterTableV12() throws SQLException {
if (usingMySQL) {
executeUnsafe("ALTER TABLE " + tableName + " MODIFY " + columnIP + " VARCHAR(39) NOT NULL");
}
}
/**
* @param uuid UUID of the user.
* @return Users's Login Geolocations.