Fix bug where serverId column was being referenced in table after it's removal.

This commit is contained in:
Ty Sayers 2015-08-29 18:04:50 -07:00
parent f21f1ca93e
commit f5b9aca708
1 changed files with 10 additions and 10 deletions

View File

@ -38,7 +38,7 @@ public class ClanRepository extends RepositoryBase
{ {
private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, serverId INT NOT NULL, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BIT(1), dateCreated DATETIME, lastOnline DATETIME, energy INT, PRIMARY KEY (id), INDEX clanName (name));"; private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, serverId INT NOT NULL, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BIT(1), dateCreated DATETIME, lastOnline DATETIME, energy INT, PRIMARY KEY (id), INDEX clanName (name));";
private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));"; private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverId INT NOT NULL, chunk VARCHAR(100), safe BIT(1), PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverId));"; private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, chunk VARCHAR(100), safe BIT(1), PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id));";
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BIT(1), PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));"; private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BIT(1), PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;"; private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;";
@ -51,9 +51,9 @@ public class ClanRepository extends RepositoryBase
private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;"; private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;";
private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;"; private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;";
private static String DELETE_CLAN_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverId = ? AND chunk = ?;"; private static String DELETE_CLAN_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND chunk = ?;";
private static String DELETE_CLAN_ALL_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverId = ?;"; private static String DELETE_CLAN_ALL_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ?;"; //
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;"; private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;"; //
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;"; private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;"; private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN_ENEMIES = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;"; private static String DELETE_CLAN_ENEMIES = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
@ -63,13 +63,13 @@ public class ClanRepository extends RepositoryBase
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;"; private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);"; private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());"; private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());";
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverId, chunk, safe) VALUES (?, ?, ?, ?);"; private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, chunk, safe) VALUES (?, ?, ?, ?);";
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, kills = ?, murder = ?, deaths = ?, warWins = ?, warLosses = ?, lastOnline = ? WHERE id = ?;"; private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, kills = ?, murder = ?, deaths = ?, warWins = ?, warLosses = ?, lastOnline = ? WHERE id = ?;";
private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;"; private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;";
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;"; private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;"; private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverId = ? AND chunk = ?;"; private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE chunk = ?;"; //
private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '', generator = '' WHERE id = ?;"; private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '', generator = '' WHERE id = ?;";
private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorStock = ? WHERE id = ?;"; private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorStock = ? WHERE id = ?;";
@ -478,7 +478,7 @@ public class ClanRepository extends RepositoryBase
public boolean addTerritoryClaim(int clanId, String chunk, boolean safe) public boolean addTerritoryClaim(int clanId, String chunk, boolean safe)
{ {
return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnInt("serverId", _serverId), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe)) == 1; return executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe)) == 1;
} }
public boolean addTerritoryClaims(int clanId, boolean safe, String... chunks) public boolean addTerritoryClaims(int clanId, boolean safe, String... chunks)
@ -530,12 +530,12 @@ public class ClanRepository extends RepositoryBase
public void removeTerritoryClaim(int clanId, String chunk) public void removeTerritoryClaim(int clanId, String chunk)
{ {
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnInt("serverId", _serverId), new ColumnVarChar("chunk", 100, chunk)); executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("chunk", 100, chunk));
} }
public void removeTerritoryClaims(int clanId) public void removeTerritoryClaims(int clanId)
{ {
executeUpdate(DELETE_CLAN_ALL_TERRITORY, new ColumnInt("clanId", clanId), new ColumnInt("serverId", _serverId)); executeUpdate(DELETE_CLAN_ALL_TERRITORY, new ColumnInt("clanId", clanId));
} }
public void updateClan(int clanId, String name, String desc, String home, boolean admin, int energy, int kills, int murder, int deaths, int warWins, int warLosses, Timestamp lastOnline) public void updateClan(int clanId, String name, String desc, String home, boolean admin, int energy, int kills, int murder, int deaths, int warWins, int warLosses, Timestamp lastOnline)
@ -560,6 +560,6 @@ public class ClanRepository extends RepositoryBase
public void updateTerritoryClaim(String chunk, boolean safe) public void updateTerritoryClaim(String chunk, boolean safe)
{ {
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnInt("serverId", _serverId), new ColumnVarChar("chunk", 100, chunk)); executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("chunk", 100, chunk));
} }
} }