-
Notifications
You must be signed in to change notification settings - Fork 54
/
head_migration.js
48 lines (37 loc) · 1.32 KB
/
head_migration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
}
// Put any other stuff relative to this test folder below.
const CURRENT_SCHEMA_VERSION = 52;
const FIRST_UPGRADABLE_SCHEMA_VERSION = 30;
async function assertAnnotationsRemoved(db, expectedAnnos) {
for (let anno of expectedAnnos) {
let rows = await db.execute(`
SELECT id FROM moz_anno_attributes
WHERE name = :anno
`, {anno});
Assert.equal(rows.length, 0, `${anno} should not exist in the database`);
}
}
async function assertNoOrphanAnnotations(db) {
let rows = await db.execute(`
SELECT item_id FROM moz_items_annos
WHERE item_id NOT IN (SELECT id from moz_bookmarks)
`);
Assert.equal(rows.length, 0,
`Should have no orphan annotations.`);
rows = await db.execute(`
SELECT id FROM moz_anno_attributes
WHERE id NOT IN (SELECT id from moz_items_annos)
`);
Assert.equal(rows.length, 0,
`Should have no orphan annotation attributes.`);
}