1.4.1 Fixing table truncation to update

This commit is contained in:
funkemunky
2021-09-09 14:53:29 -04:00
parent a3cb7e8e8a
commit c1ef2eef56
10 changed files with 34 additions and 13 deletions
@@ -192,6 +192,21 @@ public class MySqlVPN implements VPNDatabase {
MySQL.init();
System.out.println("Creating tables...");
//Running check for old table types to update
oldTableCheck: {
Query.prepare("select `DATA_TYPE` from INFORMATION_SCHEMA.COLUMNS " +
"WHERE table_name = 'responses' AND COLUMN_NAME = 'isp';").execute(set -> {
if(set.getObject("DATA_TYPE").toString().contains("varchar")) {
System.out.println("Using old database format for storing responses! " +
"Dropping table and creating a new one...");
if(Query.prepare("drop table `responses`").execute() == 1) {
System.out.println("Sucessfully dropped table!");
}
}
});
}
Query.prepare("create table if not exists `whitelisted` (`uuid` varchar(36) not null)").execute();
Query.prepare("create table if not exists `responses` (`ip` varchar(45) not null, `asn` varchar(12),"
+ "`countryName` text, `countryCode` varchar(10), `city` text, `timeZone` varchar(64), "
@@ -4,6 +4,7 @@ import dev.brighten.antivpn.AntiVPN;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MySQL {
private static Connection conn;
@@ -52,6 +53,11 @@ public class MySQL {
if(conn == null)
return true;
return conn,isClosed();
try {
return conn.isClosed();
} catch (SQLException e) {
e.printStackTrace();
return true;
}
}
}