mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-01 09:51:55 +00:00
1.4.1 Fixing table truncation to update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user