Fix DB upgrade code.

Bug: 11294681
Change-Id: I7333aabbdb9e45154d83386b85398e6d108e5bf2
diff --git a/src/com/android/email/provider/DBHelper.java b/src/com/android/email/provider/DBHelper.java
index 8a0c259..e92ed34 100644
--- a/src/com/android/email/provider/DBHelper.java
+++ b/src/com/android/email/provider/DBHelper.java
@@ -159,7 +159,8 @@
     // 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 @@
                 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