Skip to content

Commit

Permalink
Fixed #83 : Deleted corrupted leaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Neraud committed Jun 14, 2015
1 parent 2354fd3 commit 8661aad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public class PADListenerSQLiteOpenHelper extends SQLiteOpenHelper {

private static final int DB_VERSION = 11;
private static final int DB_VERSION = 12;
private static final String DATABASE_NAME = "padlistener.db";

private static final List<ITable> TABLES = new ArrayList<ITable>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,30 @@ public String dropTable() {

@Override
public int getVersion() {
return 11;
return 12;
}

@Override
public List<String> upgrade(int oldVersion, int newVersion) {
final List<String> queries = new ArrayList<String>();

if (oldVersion < getVersion()) {
MyLog.warn("Table " + CapturedPlayerFriendLeaderDescriptor.TABLE_NAME + " has changed, destroying table !");
queries.add(dropTable());
queries.add(createTable());
if (oldVersion == 11 && newVersion == 12) {
MyLog.debug("Deleting corrupted leaders");
final StringBuilder queryBuilder = new StringBuilder("DELETE FROM ");
queryBuilder.append(CapturedPlayerFriendLeaderDescriptor.TABLE_NAME);
queryBuilder.append(" WHERE ").append(CapturedPlayerFriendLeaderDescriptor.Fields.ID_JP.getColName()).append(" = -1");
queryBuilder.append(" OR ").append(CapturedPlayerFriendLeaderDescriptor.Fields.SKILL_LEVEL.getColName()).append(" > 50");
queryBuilder.append(" OR ").append(CapturedPlayerFriendLeaderDescriptor.Fields.PLUS_HP.getColName()).append(" > 99");
queryBuilder.append(" OR ").append(CapturedPlayerFriendLeaderDescriptor.Fields.PLUS_ATK.getColName()).append(" > 99");
queryBuilder.append(" OR ").append(CapturedPlayerFriendLeaderDescriptor.Fields.PLUS_RCV.getColName()).append(" > 99");
queryBuilder.append(" OR ").append(CapturedPlayerFriendLeaderDescriptor.Fields.AWAKENINGS.getColName()).append(" > 25");
queries.add(queryBuilder.toString());
} else {
MyLog.warn("Table " + CapturedPlayerFriendLeaderDescriptor.TABLE_NAME + " has changed, destroying table !");
queries.add(dropTable());
queries.add(createTable());
}
} else {
MyLog.info("Table " + CapturedPlayerFriendLeaderDescriptor.TABLE_NAME + " is already up to date (hasn't changed since version " + getVersion() + ")");
}
Expand All @@ -65,5 +78,6 @@ public void preUpgrade(Context context, int oldVersion, int newVersion) {

@Override
public void postUpgrade(Context context, int oldVersion, int newVersion) {

}
}
2 changes: 1 addition & 1 deletion PADListenerApp/src/main/res/xml/changelog_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<changelog>
<release
version="" versioncode="">
<change>Fixed #83 : Friends' leader broken</change>
<change>Fixed #83 : Friends' leader broken and deleted corrupted leaders</change>
</release>
<release
version="2.1.6" versioncode="54">
Expand Down

0 comments on commit 8661aad

Please sign in to comment.