Skip to content

Commit 83dffb5

Browse files
committed
feat: Add a few db indices
1 parent 2fc14bc commit 83dffb5

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {MigrationInterface, QueryRunner, TableIndex} from "typeorm";
2+
3+
export class AddIndices1572006450765 implements MigrationInterface {
4+
5+
public async up(queryRunner: QueryRunner): Promise<any> {
6+
await queryRunner.createIndex("input", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
7+
await queryRunner.createIndex("output", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
8+
await queryRunner.createIndex("transaction", new TableIndex({ columnNames: ["status"] }))
9+
}
10+
11+
public async down(queryRunner: QueryRunner): Promise<any> {
12+
await queryRunner.dropIndex("input", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
13+
await queryRunner.dropIndex("output", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
14+
await queryRunner.dropIndex("transaction", new TableIndex({ columnNames: ["status"] }))
15+
}
16+
17+
}

packages/neuron-wallet/src/database/chain/ormconfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { InitMigration1566959757554 } from './migrations/1566959757554-InitMigra
1313
import { AddTypeAndHasData1567144517514 } from './migrations/1567144517514-AddTypeAndHasData'
1414
import { ChangeHasDataDefault1568621556467 } from './migrations/1568621556467-ChangeHasDataDefault'
1515
import { AddLockToInput1570522869590 } from './migrations/1570522869590-AddLockToInput'
16+
import { AddIndices1572006450765 } from './migrations/1572006450765-AddIndices'
1617

1718
export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError'
1819

@@ -38,6 +39,7 @@ const connectOptions = async (genesisBlockHash: string): Promise<SqliteConnectio
3839
AddTypeAndHasData1567144517514,
3940
ChangeHasDataDefault1568621556467,
4041
AddLockToInput1570522869590,
42+
AddIndices1572006450765
4143
],
4244
logging,
4345
maxQueryExecutionTime: 100

0 commit comments

Comments
 (0)