sessionIDServerIDRelation = db.getSessionsTable().getIDServerIDRelation();
- String sql = "UPDATE " + KillsTable.TABLE_NAME + " SET " +
- KillsTable.Col.SERVER_ID + "=?" +
- " WHERE " + KillsTable.Col.SESSION_ID + "=?";
+ String sql = "UPDATE " + KillsTable.TABLE_NAME + " SET server_id=? WHERE " + KillsTable.Col.SESSION_ID + "=?";
db.executeBatch(new ExecStatement(sql) {
@Override
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java
index 4d3f004b1..da2d8cee3 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java
@@ -40,31 +40,31 @@ import java.util.*;
*
* Table Name: plan_kills
*
- * For contained columns {@see Col}
+ * Patches related to this table:
+ * {@link com.djrapitops.plan.system.database.databases.sql.patches.Version10Patch}
+ * {@link com.djrapitops.plan.system.database.databases.sql.patches.KillsServerIDPatch}
+ * {@link com.djrapitops.plan.system.database.databases.sql.patches.KillsOptimizationPatch}
*
* @author Rsl1122
*/
-public class KillsTable extends UserIDTable {
+public class KillsTable extends UserUUIDTable {
public static final String TABLE_NAME = "plan_kills";
- private final ServerTable serverTable;
+
+ private final UsersTable usersTable;
public KillsTable(SQLDB db) {
super(TABLE_NAME, db);
+ usersTable = db.getUsersTable();
sessionsTable = db.getSessionsTable();
- serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " ("
- + Col.KILLER_ID + ", "
- + Col.VICTIM_ID + ", "
- + Col.SERVER_ID + ", "
+ + Col.KILLER_UUID + ", "
+ + Col.VICTIM_UUID + ", "
+ + Col.SERVER_UUID + ", "
+ Col.SESSION_ID + ", "
+ Col.DATE + ", "
+ Col.WEAPON
- + ") VALUES ("
- + usersTable.statementSelectID + ", "
- + usersTable.statementSelectID + ", "
- + serverTable.statementSelectServerID + ", "
- + "?, ?, ?)";
+ + ") VALUES (?, ?, ?, ?, ?, ?)";
}
private final SessionsTable sessionsTable;
@@ -73,16 +73,15 @@ public class KillsTable extends UserIDTable {
@Override
public void createTable() throws DBInitException {
createTable(TableSqlParser.createTable(tableName)
- .column(Col.KILLER_ID, Sql.INT).notNull()
- .column(Col.VICTIM_ID, Sql.INT).notNull()
- .column(Col.SERVER_ID, Sql.INT).notNull()
+ .primaryKeyIDColumn(supportsMySQLQueries, Col.ID)
+ .column(Col.KILLER_UUID, Sql.varchar(36)).notNull()
+ .column(Col.VICTIM_UUID, Sql.varchar(36)).notNull()
+ .column(Col.SERVER_UUID, Sql.varchar(36)).notNull()
.column(Col.WEAPON, Sql.varchar(30)).notNull()
.column(Col.DATE, Sql.LONG).notNull()
.column(Col.SESSION_ID, Sql.INT).notNull()
- .foreignKey(Col.KILLER_ID, usersTable.getTableName(), UsersTable.Col.ID)
- .foreignKey(Col.VICTIM_ID, usersTable.getTableName(), UsersTable.Col.ID)
+ .primaryKey(supportsMySQLQueries, Col.ID)
.foreignKey(Col.SESSION_ID, sessionsTable.getTableName(), SessionsTable.Col.ID)
- .foreignKey(Col.SERVER_ID, serverTable.getTableName(), ServerTable.Col.SERVER_ID)
.toString()
);
}
@@ -90,8 +89,8 @@ public class KillsTable extends UserIDTable {
@Override
public void removeUser(UUID uuid) {
String sql = "DELETE FROM " + tableName +
- " WHERE " + Col.KILLER_ID + " = " + usersTable.statementSelectID +
- " OR " + Col.VICTIM_ID + " = " + usersTable.statementSelectID;
+ " WHERE " + Col.KILLER_UUID + "=?" +
+ " OR " + Col.VICTIM_UUID + "=?";
execute(new ExecStatement(sql) {
@Override
@@ -103,18 +102,17 @@ public class KillsTable extends UserIDTable {
}
public void addKillsToSessions(UUID uuid, Map sessions) {
- String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
- String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as victim_uuid";
+ String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID;
String usersNameColumn = usersTable + "." + UsersTable.Col.USER_NAME + " as victim_name";
String sql = "SELECT " +
Col.SESSION_ID + ", " +
Col.DATE + ", " +
Col.WEAPON + ", " +
- usersUUIDColumn + ", " +
+ Col.VICTIM_UUID + ", " +
usersNameColumn +
" FROM " + tableName +
- " INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.VICTIM_ID +
- " WHERE " + Col.KILLER_ID + "=" + usersTable.statementSelectID;
+ " INNER JOIN " + usersTable + " on " + usersUUIDColumn + "=" + Col.VICTIM_UUID +
+ " WHERE " + Col.KILLER_UUID + "=?";
query(new QueryStatement