Bug 1261907 - Post: add comments explaining why we need table-created checks r?nalexander draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 06 Apr 2016 10:32:18 -0700
changeset 348127 8d19d5ebd29561232d252762d426a909c429d497
parent 348126 639e600432ea68d09c9d10810fb5a3acfa7054e6
child 517787 490f53ad44c2876d502cbc9b5c6e5c905280c487
push id14755
push userahunt@mozilla.com
push dateWed, 06 Apr 2016 17:49:19 +0000
reviewersnalexander
bugs1261907
milestone48.0a1
Bug 1261907 - Post: add comments explaining why we need table-created checks r?nalexander MozReview-Commit-ID: 9vqjn0DLXOv
mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
@@ -1023,16 +1023,19 @@ public final class BrowserDatabaseHelper
             // We're betting that an error here means that the table already has the column,
             // so we're failing due to the duplicate column name.
             Log.e(LOGTAG, "Error upgrading database from 21 to 22", e);
         }
     }
 
     private void upgradeDatabaseFrom22to23(SQLiteDatabase db) {
         if (didCreateCurrentReadingListTable) {
+            // If we just created this table it is already in the expected >= 23 schema. Trying
+            // to run this migration will crash because columns that were in the <= 22 schema
+            // no longer exist.
             debug("No need to rev reading list schema; we just created with the current schema.");
             return;
         }
 
         debug("Rewriting reading list table.");
         createReadingListTable(db, "tmp_rl");
 
         // Remove indexes. We don't need them now, and we'll be throwing away the table.
@@ -1097,16 +1100,19 @@ public final class BrowserDatabaseHelper
             } catch (Exception e) {
                 Log.e(LOGTAG, "Exception occurred while trying to delete " + file.getPath() + "; ignoring.", e);
             }
         }
     }
 
     private void upgradeDatabaseFrom24to25(SQLiteDatabase db) {
         if (didCreateTabsTable) {
+            // This migration adds a foreign key constraint (the table scheme stays identical, except
+            // for the new constraint) - hence it is safe to run this migration on a newly created tabs
+            // table - but it's unnecessary hence we should avoid doing so.
             debug("No need to rev tabs schema; foreign key constraint exists.");
             return;
         }
 
         debug("Rewriting tabs table.");
         createTabsTable(db, "tmp_tabs");
 
         // Remove indexes. We don't need them now, and we'll be throwing away the table.