Bug 1261907 - Post: add comments explaining why we need table-created checks r?nalexander
MozReview-Commit-ID: 9vqjn0DLXOv
--- 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.