Bug 1776606: Add source and triggeringPlaceId column to moz_historyvisits table. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D150730
This commit is contained in:
@@ -1273,6 +1273,13 @@ nsresult Database::InitSchema(bool* aDatabaseMigrated) {
|
||||
|
||||
// Firefox 103 uses schema version 68
|
||||
|
||||
if (currentSchemaVersion < 69) {
|
||||
rv = MigrateV69Up();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 104 uses schema version 69
|
||||
|
||||
// Schema Upgrades must add migration code here.
|
||||
// >>> IMPORTANT! <<<
|
||||
// NEVER MIX UP SYNC AND ASYNC EXECUTION IN MIGRATORS, YOU MAY LOCK THE
|
||||
@@ -2571,6 +2578,25 @@ nsresult Database::MigrateV68Up() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Database::MigrateV69Up() {
|
||||
// Add source and annotation column to places table.
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
nsresult rv = mMainConn->CreateStatement(
|
||||
"SELECT source FROM moz_historyvisits"_ns, getter_AddRefs(stmt));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = mMainConn->ExecuteSimpleSQL(
|
||||
"ALTER TABLE moz_historyvisits "
|
||||
"ADD COLUMN source INTEGER DEFAULT 0 NOT NULL"_ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mMainConn->ExecuteSimpleSQL(
|
||||
"ALTER TABLE moz_historyvisits "
|
||||
"ADD COLUMN triggeringPlaceId INTEGER"_ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Database::ConvertOldStyleQuery(nsCString& aURL) {
|
||||
AutoTArray<QueryKeyValuePair, 8> tokens;
|
||||
nsresult rv = TokenizeQueryString(aURL, &tokens);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// This is the schema version. Update it at any schema change and add a
|
||||
// corresponding migrateVxx method below.
|
||||
#define DATABASE_SCHEMA_VERSION 68
|
||||
#define DATABASE_SCHEMA_VERSION 69
|
||||
|
||||
// Fired after Places inited.
|
||||
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
|
||||
@@ -341,6 +341,7 @@ class Database final : public nsIObserver, public nsSupportsWeakReference {
|
||||
nsresult MigrateV66Up();
|
||||
nsresult MigrateV67Up();
|
||||
nsresult MigrateV68Up();
|
||||
nsresult MigrateV69Up();
|
||||
|
||||
void MigrateV52OriginFrecencies();
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
", visit_date INTEGER" \
|
||||
", visit_type INTEGER" \
|
||||
", session INTEGER" \
|
||||
", source INTEGER DEFAULT 0 NOT NULL" \
|
||||
", triggeringPlaceId INTEGER" \
|
||||
")")
|
||||
|
||||
#define CREATE_MOZ_INPUTHISTORY \
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// Put any other stuff relative to this test folder below.
|
||||
|
||||
const CURRENT_SCHEMA_VERSION = 68;
|
||||
const CURRENT_SCHEMA_VERSION = 69;
|
||||
const FIRST_UPGRADABLE_SCHEMA_VERSION = 43;
|
||||
|
||||
async function assertAnnotationsRemoved(db, expectedAnnos) {
|
||||
|
||||
BIN
toolkit/components/places/tests/migration/places_v69.sqlite
Normal file
BIN
toolkit/components/places/tests/migration/places_v69.sqlite
Normal file
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function setup() {
|
||||
const path = await setupPlacesDatabase("places_v68.sqlite");
|
||||
|
||||
const db = await Sqlite.openConnection({ path });
|
||||
await db.execute("INSERT INTO moz_historyvisits (from_visit) VALUES (-1)");
|
||||
await db.close();
|
||||
});
|
||||
|
||||
add_task(async function database_is_valid() {
|
||||
// Accessing the database for the first time triggers migration.
|
||||
Assert.equal(
|
||||
PlacesUtils.history.databaseStatus,
|
||||
PlacesUtils.history.DATABASE_STATUS_UPGRADED
|
||||
);
|
||||
|
||||
const db = await PlacesUtils.promiseDBConnection();
|
||||
Assert.equal(await db.getSchemaVersion(), CURRENT_SCHEMA_VERSION);
|
||||
});
|
||||
|
||||
add_task(async function moz_historyvisits() {
|
||||
await PlacesUtils.withConnectionWrapper("test_sqlite_migration", async db => {
|
||||
const rows = await db.execute(
|
||||
"SELECT * FROM moz_historyvisits WHERE from_visit=-1"
|
||||
);
|
||||
|
||||
Assert.equal(rows.length, 1);
|
||||
Assert.equal(rows[0].getResultByName("source"), 0);
|
||||
Assert.equal(rows[0].getResultByName("triggeringPlaceId"), null);
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ support-files =
|
||||
places_v66.sqlite
|
||||
places_v67.sqlite
|
||||
places_v68.sqlite
|
||||
places_v69.sqlite
|
||||
|
||||
[test_current_from_downgraded.js]
|
||||
[test_current_from_outdated.js]
|
||||
@@ -31,3 +32,4 @@ skip-if = condprof # Bug 1769154 - not supported
|
||||
skip-if = condprof # Bug 1769154 - not supported
|
||||
[test_current_from_v66.js]
|
||||
[test_current_from_v67.js]
|
||||
[test_current_from_v68.js]
|
||||
|
||||
Reference in New Issue
Block a user