@ocap/indexdb-sqlite 1.30.20 → 1.30.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,36 +6,14 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ __exportAll({
|
|
|
6
6
|
down: () => down,
|
|
7
7
|
up: () => up
|
|
8
8
|
});
|
|
9
|
-
async function
|
|
10
|
-
|
|
9
|
+
async function assertRollupBlockTableExists(db) {
|
|
10
|
+
if ((await sql`
|
|
11
11
|
SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
|
|
12
|
-
`.execute(db)).rows.length
|
|
12
|
+
`.execute(db)).rows.length === 0) throw new Error("Cannot migrate rollupBlock.height: source table rollupBlock is missing. Refusing to create an empty rollupBlock index table; restore or reindex rollupBlock before rerunning this migration.");
|
|
13
13
|
}
|
|
14
|
-
async function
|
|
15
|
-
await sql`
|
|
16
|
-
|
|
17
|
-
hash TEXT PRIMARY KEY,
|
|
18
|
-
rollup TEXT,
|
|
19
|
-
height INTEGER,
|
|
20
|
-
merkleRoot TEXT,
|
|
21
|
-
previousHash TEXT,
|
|
22
|
-
txsHash TEXT,
|
|
23
|
-
txs TEXT,
|
|
24
|
-
proposer TEXT,
|
|
25
|
-
signatures TEXT,
|
|
26
|
-
rewardAmount TEXT,
|
|
27
|
-
mintedAmount TEXT,
|
|
28
|
-
burnedAmount TEXT,
|
|
29
|
-
minReward TEXT,
|
|
30
|
-
validators TEXT,
|
|
31
|
-
tokenInfo TEXT,
|
|
32
|
-
governance INTEGER,
|
|
33
|
-
data TEXT,
|
|
34
|
-
genesisTime TEXT,
|
|
35
|
-
renaissanceTime TEXT
|
|
36
|
-
)
|
|
37
|
-
`.execute(db);
|
|
38
|
-
await createRollupBlockIndexes(db);
|
|
14
|
+
async function getRollupBlockCount(db, table) {
|
|
15
|
+
const result = table === "rollupBlock" ? await sql`SELECT COUNT(*) AS count FROM rollupBlock`.execute(db) : await sql`SELECT COUNT(*) AS count FROM rollupBlock_new`.execute(db);
|
|
16
|
+
return Number(result.rows[0]?.count ?? 0);
|
|
39
17
|
}
|
|
40
18
|
async function createRollupBlockIndexes(db) {
|
|
41
19
|
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
|
|
@@ -46,10 +24,8 @@ async function createRollupBlockIndexes(db) {
|
|
|
46
24
|
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
47
25
|
}
|
|
48
26
|
async function up(db) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
27
|
+
await assertRollupBlockTableExists(db);
|
|
28
|
+
const beforeCount = await getRollupBlockCount(db, "rollupBlock");
|
|
53
29
|
await sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
|
|
54
30
|
await sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
|
|
55
31
|
await sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
|
|
@@ -124,9 +100,13 @@ async function up(db) {
|
|
|
124
100
|
renaissanceTime
|
|
125
101
|
FROM rollupBlock
|
|
126
102
|
`.execute(db);
|
|
103
|
+
const stagedCount = await getRollupBlockCount(db, "rollupBlock_new");
|
|
104
|
+
if (stagedCount !== beforeCount) throw new Error(`Cannot migrate rollupBlock.height: staged row count mismatch before replacing table (${stagedCount} !== ${beforeCount})`);
|
|
127
105
|
await sql`DROP TABLE rollupBlock`.execute(db);
|
|
128
106
|
await sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
|
|
129
107
|
await createRollupBlockIndexes(db);
|
|
108
|
+
const afterCount = await getRollupBlockCount(db, "rollupBlock");
|
|
109
|
+
if (afterCount !== beforeCount) throw new Error(`Cannot migrate rollupBlock.height: row count mismatch after replacing table (${afterCount} !== ${beforeCount})`);
|
|
130
110
|
}
|
|
131
111
|
async function down(_db) {}
|
|
132
112
|
|
|
@@ -6,36 +6,14 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ require_rolldown_
|
|
|
6
6
|
down: () => down,
|
|
7
7
|
up: () => up
|
|
8
8
|
});
|
|
9
|
-
async function
|
|
10
|
-
|
|
9
|
+
async function assertRollupBlockTableExists(db) {
|
|
10
|
+
if ((await kysely.sql`
|
|
11
11
|
SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
|
|
12
|
-
`.execute(db)).rows.length
|
|
12
|
+
`.execute(db)).rows.length === 0) throw new Error("Cannot migrate rollupBlock.height: source table rollupBlock is missing. Refusing to create an empty rollupBlock index table; restore or reindex rollupBlock before rerunning this migration.");
|
|
13
13
|
}
|
|
14
|
-
async function
|
|
15
|
-
await kysely.sql`
|
|
16
|
-
|
|
17
|
-
hash TEXT PRIMARY KEY,
|
|
18
|
-
rollup TEXT,
|
|
19
|
-
height INTEGER,
|
|
20
|
-
merkleRoot TEXT,
|
|
21
|
-
previousHash TEXT,
|
|
22
|
-
txsHash TEXT,
|
|
23
|
-
txs TEXT,
|
|
24
|
-
proposer TEXT,
|
|
25
|
-
signatures TEXT,
|
|
26
|
-
rewardAmount TEXT,
|
|
27
|
-
mintedAmount TEXT,
|
|
28
|
-
burnedAmount TEXT,
|
|
29
|
-
minReward TEXT,
|
|
30
|
-
validators TEXT,
|
|
31
|
-
tokenInfo TEXT,
|
|
32
|
-
governance INTEGER,
|
|
33
|
-
data TEXT,
|
|
34
|
-
genesisTime TEXT,
|
|
35
|
-
renaissanceTime TEXT
|
|
36
|
-
)
|
|
37
|
-
`.execute(db);
|
|
38
|
-
await createRollupBlockIndexes(db);
|
|
14
|
+
async function getRollupBlockCount(db, table) {
|
|
15
|
+
const result = table === "rollupBlock" ? await kysely.sql`SELECT COUNT(*) AS count FROM rollupBlock`.execute(db) : await kysely.sql`SELECT COUNT(*) AS count FROM rollupBlock_new`.execute(db);
|
|
16
|
+
return Number(result.rows[0]?.count ?? 0);
|
|
39
17
|
}
|
|
40
18
|
async function createRollupBlockIndexes(db) {
|
|
41
19
|
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
|
|
@@ -46,10 +24,8 @@ async function createRollupBlockIndexes(db) {
|
|
|
46
24
|
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
47
25
|
}
|
|
48
26
|
async function up(db) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
27
|
+
await assertRollupBlockTableExists(db);
|
|
28
|
+
const beforeCount = await getRollupBlockCount(db, "rollupBlock");
|
|
53
29
|
await kysely.sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
|
|
54
30
|
await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
|
|
55
31
|
await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
|
|
@@ -124,9 +100,13 @@ async function up(db) {
|
|
|
124
100
|
renaissanceTime
|
|
125
101
|
FROM rollupBlock
|
|
126
102
|
`.execute(db);
|
|
103
|
+
const stagedCount = await getRollupBlockCount(db, "rollupBlock_new");
|
|
104
|
+
if (stagedCount !== beforeCount) throw new Error(`Cannot migrate rollupBlock.height: staged row count mismatch before replacing table (${stagedCount} !== ${beforeCount})`);
|
|
127
105
|
await kysely.sql`DROP TABLE rollupBlock`.execute(db);
|
|
128
106
|
await kysely.sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
|
|
129
107
|
await createRollupBlockIndexes(db);
|
|
108
|
+
const afterCount = await getRollupBlockCount(db, "rollupBlock");
|
|
109
|
+
if (afterCount !== beforeCount) throw new Error(`Cannot migrate rollupBlock.height: row count mismatch after replacing table (${afterCount} !== ${beforeCount})`);
|
|
130
110
|
}
|
|
131
111
|
async function down(_db) {}
|
|
132
112
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/indexdb-sqlite",
|
|
3
3
|
"description": "OCAP indexdb adapter that uses SQLite as backend",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.21",
|
|
5
5
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/ArcBlock/blockchain/issues",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"clean": "rm -rf lib esm"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@arcblock/did": "1.30.
|
|
65
|
-
"@ocap/indexdb": "1.30.
|
|
66
|
-
"@ocap/types": "1.30.
|
|
67
|
-
"@ocap/util": "1.30.
|
|
64
|
+
"@arcblock/did": "1.30.21",
|
|
65
|
+
"@ocap/indexdb": "1.30.21",
|
|
66
|
+
"@ocap/types": "1.30.21",
|
|
67
|
+
"@ocap/util": "1.30.21",
|
|
68
68
|
"debug": "^4.4.3",
|
|
69
69
|
"better-sqlite3": "^11.8.1",
|
|
70
70
|
"kysely": "^0.28.14",
|