am 7b7d7d5c: Fix DB upgrade code.

* commit '7b7d7d5cb57c9f0e589b686511eabf3c73f96f00':
  Fix DB upgrade code.
This commit is contained in:
Yu Ping Hu 2013-10-25 08:44:50 -07:00 committed by Android Git Automerger
commit 8c50fe285d
1 changed files with 11 additions and 1 deletions

View File

@ -159,7 +159,8 @@ public final class DBHelper {
// Version 121: Add mainMailboxKey, which will be set for messages that are in the fake
// "search_results" folder to reflect the mailbox that the server considers
// the message to be in. Also, wipe out any stale search_result folders.
public static final int DATABASE_VERSION = 121;
// Version 122: Need to update Message_Updates and Message_Deletes to match previous.
public static final int DATABASE_VERSION = 122;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@ -1286,6 +1287,15 @@ public final class DBHelper {
db.execSQL("delete from " + Mailbox.TABLE_NAME + " where "
+ Mailbox.TYPE + "=" + Mailbox.TYPE_SEARCH);
}
if (oldVersion <= 121) {
// The previous update omitted making these changes to the Message_Updates and
// Message_Deletes tables. The app will actually crash in between these versions!
db.execSQL("alter table " + Message.UPDATED_TABLE_NAME
+ " add " + MessageColumns.MAIN_MAILBOX_KEY + " integer");
db.execSQL("alter table " + Message.DELETED_TABLE_NAME
+ " add " + MessageColumns.MAIN_MAILBOX_KEY + " integer");
}
}
@Override