Skip to content

Commit

Permalink
feat: Add a few db indices
Browse files Browse the repository at this point in the history
  • Loading branch information
ashchan committed Oct 28, 2019
1 parent 2fc14bc commit 83dffb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {MigrationInterface, QueryRunner, TableIndex} from "typeorm";

export class AddIndices1572006450765 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createIndex("input", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
await queryRunner.createIndex("output", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
await queryRunner.createIndex("transaction", new TableIndex({ columnNames: ["status"] }))
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropIndex("input", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
await queryRunner.dropIndex("output", new TableIndex({ columnNames: ["transactionHash", "lockHash"] }))
await queryRunner.dropIndex("transaction", new TableIndex({ columnNames: ["status"] }))
}

}
2 changes: 2 additions & 0 deletions packages/neuron-wallet/src/database/chain/ormconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { InitMigration1566959757554 } from './migrations/1566959757554-InitMigra
import { AddTypeAndHasData1567144517514 } from './migrations/1567144517514-AddTypeAndHasData'
import { ChangeHasDataDefault1568621556467 } from './migrations/1568621556467-ChangeHasDataDefault'
import { AddLockToInput1570522869590 } from './migrations/1570522869590-AddLockToInput'
import { AddIndices1572006450765 } from './migrations/1572006450765-AddIndices'

export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError'

Expand All @@ -38,6 +39,7 @@ const connectOptions = async (genesisBlockHash: string): Promise<SqliteConnectio
AddTypeAndHasData1567144517514,
ChangeHasDataDefault1568621556467,
AddLockToInput1570522869590,
AddIndices1572006450765
],
logging,
maxQueryExecutionTime: 100
Expand Down

0 comments on commit 83dffb5

Please sign in to comment.