@ocap/indexdb-sqlite 1.30.19 → 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,7 +6,26 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ __exportAll({
|
|
|
6
6
|
down: () => down,
|
|
7
7
|
up: () => up
|
|
8
8
|
});
|
|
9
|
+
async function assertRollupBlockTableExists(db) {
|
|
10
|
+
if ((await sql`
|
|
11
|
+
SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
|
|
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
|
+
}
|
|
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);
|
|
17
|
+
}
|
|
18
|
+
async function createRollupBlockIndexes(db) {
|
|
19
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
|
|
20
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
|
|
21
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
|
|
22
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
|
|
23
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
|
|
24
|
+
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
25
|
+
}
|
|
9
26
|
async function up(db) {
|
|
27
|
+
await assertRollupBlockTableExists(db);
|
|
28
|
+
const beforeCount = await getRollupBlockCount(db, "rollupBlock");
|
|
10
29
|
await sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
|
|
11
30
|
await sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
|
|
12
31
|
await sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
|
|
@@ -81,14 +100,13 @@ async function up(db) {
|
|
|
81
100
|
renaissanceTime
|
|
82
101
|
FROM rollupBlock
|
|
83
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})`);
|
|
84
105
|
await sql`DROP TABLE rollupBlock`.execute(db);
|
|
85
106
|
await sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
|
|
86
|
-
await
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
|
|
90
|
-
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
|
|
91
|
-
await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
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})`);
|
|
92
110
|
}
|
|
93
111
|
async function down(_db) {}
|
|
94
112
|
|
|
@@ -6,7 +6,26 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ require_rolldown_
|
|
|
6
6
|
down: () => down,
|
|
7
7
|
up: () => up
|
|
8
8
|
});
|
|
9
|
+
async function assertRollupBlockTableExists(db) {
|
|
10
|
+
if ((await kysely.sql`
|
|
11
|
+
SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
|
|
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
|
+
}
|
|
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);
|
|
17
|
+
}
|
|
18
|
+
async function createRollupBlockIndexes(db) {
|
|
19
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
|
|
20
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
|
|
21
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
|
|
22
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
|
|
23
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
|
|
24
|
+
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
25
|
+
}
|
|
9
26
|
async function up(db) {
|
|
27
|
+
await assertRollupBlockTableExists(db);
|
|
28
|
+
const beforeCount = await getRollupBlockCount(db, "rollupBlock");
|
|
10
29
|
await kysely.sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
|
|
11
30
|
await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
|
|
12
31
|
await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
|
|
@@ -81,14 +100,13 @@ async function up(db) {
|
|
|
81
100
|
renaissanceTime
|
|
82
101
|
FROM rollupBlock
|
|
83
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})`);
|
|
84
105
|
await kysely.sql`DROP TABLE rollupBlock`.execute(db);
|
|
85
106
|
await kysely.sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
|
|
86
|
-
await
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
|
|
90
|
-
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
|
|
91
|
-
await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
|
|
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})`);
|
|
92
110
|
}
|
|
93
111
|
async function down(_db) {}
|
|
94
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",
|