зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1426554 - Add a key-value metadata table to Places. r=mak
MozReview-Commit-ID: 3Q8FQmorZrM --HG-- extra : rebase_source : f9b8c429f7377e1ee8ce8543d07b178b06c01703
This commit is contained in:
Родитель
7365796c4a
Коммит
2ee395248f
|
@ -1233,7 +1233,12 @@ Database::InitSchema(bool* aDatabaseMigrated)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 61 uses schema version 44.
|
||||
if (currentSchemaVersion < 45) {
|
||||
rv = MigrateV45Up();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 61 uses schema version 45.
|
||||
|
||||
// Schema Upgrades must add migration code here.
|
||||
// >>> IMPORTANT! <<<
|
||||
|
@ -1318,6 +1323,10 @@ Database::InitSchema(bool* aDatabaseMigrated)
|
|||
rv = mMainConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// moz_meta.
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_META);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Initialize the bookmark roots in the new DB.
|
||||
rv = CreateBookmarkRoots();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -2073,6 +2082,20 @@ Database::MigrateV44Up() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Database::MigrateV45Up() {
|
||||
nsCOMPtr<mozIStorageStatement> metaTableStmt;
|
||||
nsresult rv = mMainConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT 1 FROM moz_meta"
|
||||
), getter_AddRefs(metaTableStmt));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_META);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Database::GetItemsWithAnno(const nsACString& aAnnoName, int32_t aItemType,
|
||||
nsTArray<int64_t>& aItemIds)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
// This is the schema version. Update it at any schema change and add a
|
||||
// corresponding migrateVxx method below.
|
||||
#define DATABASE_SCHEMA_VERSION 44
|
||||
#define DATABASE_SCHEMA_VERSION 45
|
||||
|
||||
// Fired after Places inited.
|
||||
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
|
||||
|
@ -305,6 +305,7 @@ protected:
|
|||
nsresult MigrateV42Up();
|
||||
nsresult MigrateV43Up();
|
||||
nsresult MigrateV44Up();
|
||||
nsresult MigrateV45Up();
|
||||
|
||||
nsresult UpdateBookmarkRootTitles();
|
||||
|
||||
|
|
|
@ -221,4 +221,15 @@
|
|||
") WITHOUT ROWID " \
|
||||
)
|
||||
|
||||
// This table holds key-value metadata for Places and its consumers. Sync stores
|
||||
// the sync IDs for the bookmarks and history collections in this table, and the
|
||||
// last sync time for history.
|
||||
#define CREATE_MOZ_META NS_LITERAL_CSTRING( \
|
||||
"CREATE TABLE moz_meta (" \
|
||||
"key TEXT PRIMARY KEY, " \
|
||||
"value NOT NULL" \
|
||||
") WITHOUT ROWID " \
|
||||
)
|
||||
|
||||
|
||||
#endif // __nsPlacesTables_h__
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const CURRENT_SCHEMA_VERSION = 44;
|
||||
const CURRENT_SCHEMA_VERSION = 45;
|
||||
const FIRST_UPGRADABLE_SCHEMA_VERSION = 30;
|
||||
|
||||
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
||||
|
|
|
@ -208,3 +208,8 @@ add_task(async function test_no_orphan_keywords() {
|
|||
Assert.equal(rows.length, 0,
|
||||
`Should have no orphan keywords.`);
|
||||
});
|
||||
|
||||
add_task(async function test_meta_exists() {
|
||||
let db = await PlacesUtils.promiseDBConnection();
|
||||
await db.execute(`SELECT 1 FROM moz_meta`);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче