Bug 1549912 - Support downgrade versioning of permissions database, r=mayhemer
☠☠ backed out by 34287cc2fba8 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 16 May 2019 14:24:45 +0000
changeset 532961 f8dfee6dc6e57a2a27978313a0409db058a08255
parent 532960 8c0b5bf5f7b31fdf53961aa0f5837bdf4c22b7e3
child 532962 8a9694ac64f199178bea35d73467d23ed7a44feb
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1549912
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549912 - Support downgrade versioning of permissions database, r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D31192
extensions/permissions/nsPermissionManager.cpp
--- a/extensions/permissions/nsPermissionManager.cpp
+++ b/extensions/permissions/nsPermissionManager.cpp
@@ -1567,68 +1567,18 @@ nsresult nsPermissionManager::InitDB(boo
 
         rv = mDBConn->SetSchemaVersion(9);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
         // fall through to the next upgrade
         MOZ_FALLTHROUGH;
 
-      // Version 10 removes appId from moz_hosts. SQLite doesn't support the
-      // dropping of columns from existing tables. We need to create a temporary
-      // table, copy the data, drop the old table, rename the new one.
       case 9: {
-        rv = mDBConn->BeginTransaction();
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        bool tableExists = false;
-        mDBConn->TableExists(NS_LITERAL_CSTRING("moz_hosts_v9"), &tableExists);
-        if (tableExists) {
-          NS_WARNING(
-              "The temporary database moz_hosts_v9 already exists, dropping "
-              "it.");
-          rv = mDBConn->ExecuteSimpleSQL(
-              NS_LITERAL_CSTRING("DROP TABLE moz_hosts_v9"));
-          NS_ENSURE_SUCCESS(rv, rv);
-        }
-
-        rv = mDBConn->ExecuteSimpleSQL(
-            NS_LITERAL_CSTRING("CREATE TABLE moz_hosts_v9 ("
-                               " id INTEGER PRIMARY KEY"
-                               ",host TEXT"
-                               ",type TEXT"
-                               ",permission INTEGER"
-                               ",expireType INTEGER"
-                               ",expireTime INTEGER"
-                               ",modificationTime INTEGER"
-                               ",isInBrowserElement INTEGER"
-                               ")"));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
-            "INSERT INTO moz_hosts_v9 "
-            "(id, host, type, permission, expireType, "
-            "expireTime, modificationTime, isInBrowserElement) "
-            "SELECT id, host, type, permission, expireType, expireTime, "
-            "modificationTime, isInBrowserElement FROM moz_hosts WHERE appId = "
-            "0"));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        rv = mDBConn->ExecuteSimpleSQL(
-            NS_LITERAL_CSTRING("DROP TABLE moz_hosts"));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        rv = mDBConn->ExecuteSimpleSQL(
-            NS_LITERAL_CSTRING("ALTER TABLE moz_hosts_v9 RENAME TO moz_hosts"));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        rv = mDBConn->SetSchemaVersion(10);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        rv = mDBConn->CommitTransaction();
+        rv = mDBConn->SetSchemaVersion(HOSTS_SCHEMA_VERSION);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
         // fall through to the next upgrade
         MOZ_FALLTHROUGH;
 
       // current version.
       case HOSTS_SCHEMA_VERSION: