mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-06 19:01:03 +01:00
[#860] Fixed MySQL errno 150
Fixed by disabling foreign key checks before applying patches and enabling afterwards. Error was caused by re-creation of plan_sessions table during plan_world_times creation (This was done by the database engine), but plan_sessions was referenced by temp_world_times and so could not be recreated as those references would become invalid.
This commit is contained in:
parent
8edc621761
commit
4767de6687
@ -31,7 +31,7 @@ public class DiskUsagePatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(TPSTable.TABLE_NAME,
|
||||
TPSTable.Col.FREE_DISK + " bigint NOT NULL DEFAULT -1"
|
||||
);
|
||||
|
@ -31,7 +31,7 @@ public class GeoInfoLastUsedPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(GeoInfoTable.TABLE_NAME,
|
||||
GeoInfoTable.Col.LAST_USED + " bigint NOT NULL DEFAULT 0"
|
||||
);
|
||||
|
@ -41,7 +41,7 @@ public class GeoInfoOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getGeoInfoTable().createTable();
|
||||
|
@ -68,7 +68,7 @@ public class IPAnonPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
Map<UUID, List<GeoInfo>> allGeoInfo = db.getGeoInfoTable().getAllGeoInfo();
|
||||
anonymizeIPs(allGeoInfo);
|
||||
groupHashedIPs();
|
||||
|
@ -31,7 +31,7 @@ public class IPHashPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(GeoInfoTable.TABLE_NAME, GeoInfoTable.Col.IP_HASH.get() + " varchar(200) DEFAULT ''");
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class KillsOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getKillsTable().createTable();
|
||||
|
@ -58,7 +58,7 @@ public class KillsServerIDPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(KillsTable.TABLE_NAME, "server_id integer NOT NULL DEFAULT 0");
|
||||
|
||||
Map<Integer, Integer> sessionIDServerIDRelation = db.getSessionsTable().getIDServerIDRelation();
|
||||
|
@ -41,7 +41,7 @@ public class NicknameLastSeenPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(NicknamesTable.TABLE_NAME,
|
||||
NicknamesTable.Col.LAST_USED + " bigint NOT NULL DEFAULT '0'"
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ public class NicknamesOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getNicknamesTable().createTable();
|
||||
|
@ -45,7 +45,21 @@ public abstract class Patch {
|
||||
|
||||
public abstract boolean hasBeenApplied();
|
||||
|
||||
public abstract void apply();
|
||||
protected abstract void applyPatch();
|
||||
|
||||
public void apply() {
|
||||
if (dbType == DBType.MYSQL) disableForeignKeyChecks();
|
||||
applyPatch();
|
||||
if (dbType == DBType.MYSQL) enableForeignKeyChecks();
|
||||
}
|
||||
|
||||
private void enableForeignKeyChecks() {
|
||||
db.execute("SET FOREIGN_KEY_CHECKS=1");
|
||||
}
|
||||
|
||||
private void disableForeignKeyChecks() {
|
||||
db.execute("SET FOREIGN_KEY_CHECKS=0");
|
||||
}
|
||||
|
||||
public <T> T query(QueryStatement<T> query) {
|
||||
return db.query(query);
|
||||
|
@ -42,7 +42,7 @@ public class PingOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getPingTable().createTable();
|
||||
|
@ -31,7 +31,7 @@ public class SessionAFKTimePatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
addColumn(SessionsTable.TABLE_NAME,
|
||||
SessionsTable.Col.AFK_TIME + " bigint NOT NULL DEFAULT 0"
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ public class SessionsOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
dropForeignKeys(tableName);
|
||||
ensureNoForeignKeyConstraints(tableName);
|
||||
|
@ -30,7 +30,7 @@ public class TransferTableRemovalPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
dropTable("plan_transfer");
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class UserInfoOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getUserInfoTable().createTable();
|
||||
|
@ -37,7 +37,7 @@ public class Version10Patch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(getServerUUID());
|
||||
if (!fetchedServerID.isPresent()) {
|
||||
|
@ -30,7 +30,7 @@ public class VersionTableRemovalPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
dropTable("plan_version");
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class WorldTimesOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
tempOldTable();
|
||||
db.getWorldTimesTable().createTable();
|
||||
|
@ -59,7 +59,7 @@ public class WorldTimesSeverIDPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
Map<Integer, Integer> sessionIDServerIDRelation = db.getSessionsTable().getIDServerIDRelation();
|
||||
|
||||
String sql = "UPDATE " + WorldTimesTable.TABLE_NAME + " SET " +
|
||||
|
@ -41,7 +41,7 @@ public class WorldsOptimizationPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
try {
|
||||
dropForeignKeys(tableName);
|
||||
ensureNoForeignKeyConstraints(tableName);
|
||||
|
@ -64,7 +64,7 @@ public class WorldsServerIDPatch extends Patch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
protected void applyPatch() {
|
||||
WorldTable worldTable = db.getWorldTable();
|
||||
|
||||
List<UUID> serverUUIDs = db.getServerTable().getServerUUIDs();
|
||||
|
@ -111,7 +111,7 @@ public abstract class CommonDBTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
public void applyPatch() {
|
||||
dropTable("plan_world_times");
|
||||
dropTable("plan_kills");
|
||||
dropTable("plan_sessions");
|
||||
|
Loading…
Reference in New Issue
Block a user