mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-08-02 12:14:41 +02:00
Fix SQLite drop index
This commit is contained in:
@@ -50,6 +50,7 @@ public class Storage {
|
|||||||
try {
|
try {
|
||||||
con = dataSource.getConnection();
|
con = dataSource.getConnection();
|
||||||
createStmt = con.createStatement();
|
createStmt = con.createStatement();
|
||||||
|
|
||||||
String createDataStmt = "CREATE TABLE IF NOT EXISTS " + PREMIUM_TABLE + " ("
|
String createDataStmt = "CREATE TABLE IF NOT EXISTS " + PREMIUM_TABLE + " ("
|
||||||
+ "UserID INTEGER PRIMARY KEY AUTO_INCREMENT, "
|
+ "UserID INTEGER PRIMARY KEY AUTO_INCREMENT, "
|
||||||
+ "UUID CHAR(36), "
|
+ "UUID CHAR(36), "
|
||||||
@@ -57,6 +58,7 @@ public class Storage {
|
|||||||
+ "Premium BOOLEAN NOT NULL, "
|
+ "Premium BOOLEAN NOT NULL, "
|
||||||
+ "LastIp VARCHAR(255) NOT NULL, "
|
+ "LastIp VARCHAR(255) NOT NULL, "
|
||||||
+ "LastLogin TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
|
+ "LastLogin TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
|
||||||
|
// + "UNIQUE (UUID), "
|
||||||
//the premium shouldn't steal the cracked account by changing the name
|
//the premium shouldn't steal the cracked account by changing the name
|
||||||
+ "UNIQUE (Name) "
|
+ "UNIQUE (Name) "
|
||||||
+ ")";
|
+ ")";
|
||||||
@@ -67,9 +69,16 @@ public class Storage {
|
|||||||
|
|
||||||
createStmt.executeUpdate(createDataStmt);
|
createStmt.executeUpdate(createDataStmt);
|
||||||
|
|
||||||
//drop the old unique index
|
//drop the old unique uuid index
|
||||||
try {
|
try {
|
||||||
|
if (dataSource.getJdbcUrl().contains("sqlite")) {
|
||||||
|
//create a temp table insert it there and then back
|
||||||
|
createStmt.executeUpdate(createDataStmt.replace(PREMIUM_TABLE, PREMIUM_TABLE + "-TEMP"));
|
||||||
|
createStmt.executeUpdate("INSERT INTO " + PREMIUM_TABLE + "-2 SELECT * FROM " + PREMIUM_TABLE);
|
||||||
|
createStmt.executeUpdate("INSERT INTO " + PREMIUM_TABLE + " SELECT * FROM " + PREMIUM_TABLE + "-TEMP");
|
||||||
|
} else {
|
||||||
createStmt.executeUpdate("ALTER TABLE premium DROP INDEX UUID");
|
createStmt.executeUpdate("ALTER TABLE premium DROP INDEX UUID");
|
||||||
|
}
|
||||||
} catch (SQLException sqlEx) {
|
} catch (SQLException sqlEx) {
|
||||||
core.getLogger().log(Level.FINE, "Error dropping unique uuid index", sqlEx);
|
core.getLogger().log(Level.FINE, "Error dropping unique uuid index", sqlEx);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user