Fix bug 530842 - Upgrade Sunbird/Lightning 0.9 to 1.0pre fails [error: no such table: idx_cal_alarms_cal_id_item_id_recurrence_id_recurrence_id_tz] (regression). r=mschroeder,ssitter
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 25 Nov 2009 10:34:46 +0100
changeset 4447 c57a33c9ffbfc8a2d40236acb5881123388c1996
parent 4446 8e5f6abcd3a31d450b54b7e75f65397101fd2eb4
child 4448 d577d67445863ac366e9ec9f4277d509fe374856
push id3476
push usermozilla@kewis.ch
push dateWed, 25 Nov 2009 09:37:14 +0000
treeherdercomm-central@c57a33c9ffbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmschroeder, ssitter
bugs530842
Fix bug 530842 - Upgrade Sunbird/Lightning 0.9 to 1.0pre fails [error: no such table: idx_cal_alarms_cal_id_item_id_recurrence_id_recurrence_id_tz] (regression). r=mschroeder,ssitter
calendar/providers/storage/calStorageCalendar.js
calendar/providers/storage/calStorageUpgrade.jsm
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -209,19 +209,21 @@ calStorageCalendar.prototype = {
                 }
                 try {
                     // hold lock on storage.sdb until we've migrated data from storage.sdb:
                     this.mDB.beginTransactionAs(Components.interfaces.mozIStorageConnection.TRANSACTION_EXCLUSIVE);
                     try {
                         if (this.mDB.tableExists("cal_events")) { // check again (with lock)
                             // take over data and drop from storage.sdb tables:
                             for (let table in getSqlTable(DB_SCHEMA_VERSION)) {
-                                this.mDB.executeSimpleSQL("CREATE TABLE local_sqlite." +  table +
-                                                          " AS SELECT * FROM " + table +
-                                                          "; DROP TABLE IF EXISTS " +  table);
+                                if (table.substr(0, 4) != "idx_") {
+                                    this.mDB.executeSimpleSQL("CREATE TABLE local_sqlite." +  table +
+                                                              " AS SELECT * FROM " + table +
+                                                              "; DROP TABLE IF EXISTS " +  table);
+                                }
                             }
                             this.mDB.commitTransaction();
                         } else { // migration done in the meantime
                             this.mDB.rollbackTransaction();
                         }
                     } catch (exc) {
                         cal.ERROR(exc + ", error: " + this.mDB.lastErrorString);
                         this.mDB.rollbackTransaction();
--- a/calendar/providers/storage/calStorageUpgrade.jsm
+++ b/calendar/providers/storage/calStorageUpgrade.jsm
@@ -153,17 +153,18 @@ function getAllSql(version) {
     for (let tblName in tblData) {
         sql += getSql(tblName, tblData) + "\n\n";
     }
     cal.LOG("Storage: Full SQL statement is " + sql);
     return sql;
 }
 
 /**
- * Get the JS object corresponding to the given schema version
+ * Get the JS object corresponding to the given schema version. This object will
+ * contain both tables and indexes, where indexes are prefixed with "idx_".
  *
  * @param schemaVersion       The schema version to get. If null, the latest
  *                              schema version will be used.
  * @return                    The javascript object containing the table
  *                              definition.
  */
 function getSqlTable(schemaVersion) {
     let version = "v" + (schemaVersion || DB_SCHEMA_VERSION);