@ocap/indexdb-sqlite 1.30.19 → 1.30.20

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,50 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ __exportAll({
6
6
  down: () => down,
7
7
  up: () => up
8
8
  });
9
+ async function hasRollupBlockTable(db) {
10
+ return (await sql`
11
+ SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
12
+ `.execute(db)).rows.length > 0;
13
+ }
14
+ async function createRollupBlockTable(db) {
15
+ await sql`
16
+ CREATE TABLE IF NOT EXISTS rollupBlock (
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);
39
+ }
40
+ async function createRollupBlockIndexes(db) {
41
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
42
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
43
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
44
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
45
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
46
+ await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
47
+ }
9
48
  async function up(db) {
49
+ if (!await hasRollupBlockTable(db)) {
50
+ await createRollupBlockTable(db);
51
+ return;
52
+ }
10
53
  await sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
11
54
  await sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
12
55
  await sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
@@ -83,12 +126,7 @@ async function up(db) {
83
126
  `.execute(db);
84
127
  await sql`DROP TABLE rollupBlock`.execute(db);
85
128
  await sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
86
- await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
87
- await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
88
- await sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
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);
129
+ await createRollupBlockIndexes(db);
92
130
  }
93
131
  async function down(_db) {}
94
132
 
@@ -6,7 +6,50 @@ var _006_rollup_block_height_integer_exports = /* @__PURE__ */ require_rolldown_
6
6
  down: () => down,
7
7
  up: () => up
8
8
  });
9
+ async function hasRollupBlockTable(db) {
10
+ return (await kysely.sql`
11
+ SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'rollupBlock'
12
+ `.execute(db)).rows.length > 0;
13
+ }
14
+ async function createRollupBlockTable(db) {
15
+ await kysely.sql`
16
+ CREATE TABLE IF NOT EXISTS rollupBlock (
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);
39
+ }
40
+ async function createRollupBlockIndexes(db) {
41
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
42
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
43
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
44
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_genesis ON rollupBlock(genesisTime)`.execute(db);
45
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_renaissance ON rollupBlock(renaissanceTime)`.execute(db);
46
+ await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup_genesis ON rollupBlock(rollup, genesisTime DESC)`.execute(db);
47
+ }
9
48
  async function up(db) {
49
+ if (!await hasRollupBlockTable(db)) {
50
+ await createRollupBlockTable(db);
51
+ return;
52
+ }
10
53
  await kysely.sql`DROP TABLE IF EXISTS rollupBlock_new`.execute(db);
11
54
  await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_rollup`.execute(db);
12
55
  await kysely.sql`DROP INDEX IF EXISTS idx_rollupblock_height`.execute(db);
@@ -83,12 +126,7 @@ async function up(db) {
83
126
  `.execute(db);
84
127
  await kysely.sql`DROP TABLE rollupBlock`.execute(db);
85
128
  await kysely.sql`ALTER TABLE rollupBlock_new RENAME TO rollupBlock`.execute(db);
86
- await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_rollup ON rollupBlock(rollup)`.execute(db);
87
- await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_height ON rollupBlock(height)`.execute(db);
88
- await kysely.sql`CREATE INDEX IF NOT EXISTS idx_rollupblock_proposer ON rollupBlock(proposer)`.execute(db);
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);
129
+ await createRollupBlockIndexes(db);
92
130
  }
93
131
  async function down(_db) {}
94
132
 
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.19",
4
+ "version": "1.30.20",
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.19",
65
- "@ocap/indexdb": "1.30.19",
66
- "@ocap/types": "1.30.19",
67
- "@ocap/util": "1.30.19",
64
+ "@arcblock/did": "1.30.20",
65
+ "@ocap/indexdb": "1.30.20",
66
+ "@ocap/types": "1.30.20",
67
+ "@ocap/util": "1.30.20",
68
68
  "debug": "^4.4.3",
69
69
  "better-sqlite3": "^11.8.1",
70
70
  "kysely": "^0.28.14",