Attempt to fix issue #2158

This commit is contained in:
Gabriele C
2020-07-17 18:07:42 +02:00
parent a1021f9dc3
commit e291a0415b
5 changed files with 26 additions and 38 deletions
@@ -184,9 +184,6 @@ public class SQLite extends AbstractSqlDataSource {
if (isColumnMissing(md, col.TOTP_KEY)) {
st.executeUpdate("ALTER TABLE " + tableName
+ " ADD COLUMN " + col.TOTP_KEY + " VARCHAR(32);");
} else if (isColumnSizeIncorrect(md, col.TOTP_KEY, 32)) {
st.executeUpdate("ALTER TABLE " + tableName
+ " ALTER COLUMN " + col.TOTP_KEY + " VARCHAR(32);");
}
if (!col.PLAYER_UUID.isEmpty() && isColumnMissing(md, col.PLAYER_UUID)) {
@@ -217,16 +214,6 @@ public class SQLite extends AbstractSqlDataSource {
}
}
private boolean isColumnSizeIncorrect(DatabaseMetaData metaData, String columnName, int size) throws SQLException {
try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName)) {
if (!rs.next()) {
throw new RuntimeException("Column " + columnName + " doesn't exist!");
}
int currentSize = rs.getInt("COLUMN_SIZE");
return size != currentSize;
}
}
@Override
public void reload() {
close(con);