-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core-database): add block and transactions indexes migration (#3892
- Loading branch information
1 parent
5222b5c
commit b42bfb6
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...core-database/src/migrations/20200304000000-add-type_group-index-to-transactions-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class AddTypeGroupIndexToTransactionsTable20200304000000 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query(` | ||
CREATE INDEX transactions_type_group ON transactions(type_group); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query(` | ||
DROP INDEX transactions_type_group; | ||
`); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
packages/core-database/src/migrations/20200317000000-add-blocks-and-transactions-indexes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class AddBlocksAndTransactionsIndexes20200317000000 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query(` | ||
CREATE INDEX transactions_asset ON transactions(asset); | ||
CREATE INDEX transactions_amount ON transactions(amount); | ||
CREATE INDEX transactions_fee ON transactions(fee); | ||
CREATE INDEX transactions_nonce_idx ON transactions(nonce); | ||
CREATE INDEX transactions_vendor_field ON transactions(vendor_field); | ||
CREATE INDEX transactions_version ON transactions(version); | ||
CREATE INDEX transactions_amount_sequence ON transactions(amount, sequence); | ||
CREATE INDEX transactions_fee_sequence ON transactions(fee, sequence); | ||
CREATE INDEX transactions_nonce_sequence ON transactions(nonce, sequence); | ||
CREATE INDEX transactions_timestamp_sequence ON transactions(timestamp, sequence); | ||
CREATE INDEX transactions_type_sequence ON transactions(type, sequence); | ||
CREATE INDEX transactions_type_group_sequence ON transactions(type_group, sequence); | ||
CREATE INDEX transactions_vendor_field_sequence ON transactions(vendor_field, sequence); | ||
CREATE INDEX transactions_version_sequence ON transactions(version, sequence); | ||
CREATE INDEX transactions_amount_asc_sequence ON transactions(amount ASC, sequence DESC); | ||
CREATE INDEX transactions_fee_asc_sequence ON transactions(fee ASC, sequence DESC); | ||
CREATE INDEX transactions_nonce_asc_sequence ON transactions(nonce ASC, sequence DESC); | ||
CREATE INDEX transactions_timestamp_asc_sequence ON transactions(timestamp ASC, sequence DESC); | ||
CREATE INDEX transactions_type_asc_sequence ON transactions(type ASC, sequence DESC); | ||
CREATE INDEX transactions_type_group_asc_sequence ON transactions(type_group ASC, sequence DESC); | ||
CREATE INDEX transactions_vendor_field_asc_sequence ON transactions(vendor_field ASC, sequence DESC); | ||
CREATE INDEX transactions_version_asc_sequence ON transactions(version ASC, sequence DESC); | ||
CREATE INDEX blocks_number_of_transactions ON blocks(number_of_transactions); | ||
CREATE INDEX blocks_reward ON blocks(reward); | ||
CREATE INDEX blocks_total_amount ON blocks(total_amount); | ||
CREATE INDEX blocks_total_fee ON blocks(total_fee); | ||
CREATE INDEX blocks_version ON blocks(version); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query(` | ||
DROP INDEX transactions_asset; | ||
DROP INDEX transactions_amount; | ||
DROP INDEX transactions_fee; | ||
DROP INDEX transactions_nonce_idx; | ||
DROP INDEX transactions_vendor_field; | ||
DROP INDEX transactions_version; | ||
DROP INDEX transactions_amount_sequence; | ||
DROP INDEX transactions_fee_sequence; | ||
DROP INDEX transactions_nonce_sequence; | ||
DROP INDEX transactions_timestamp_sequence; | ||
DROP INDEX transactions_type_sequence; | ||
DROP INDEX transactions_type_group_sequence; | ||
DROP INDEX transactions_vendor_field_sequence; | ||
DROP INDEX transactions_version_sequence; | ||
DROP INDEX transactions_amount_asc_sequence; | ||
DROP INDEX transactions_fee_asc_sequence; | ||
DROP INDEX transactions_nonce_asc_sequence; | ||
DROP INDEX transactions_timestamp_asc_sequence; | ||
DROP INDEX transactions_type_asc_sequence; | ||
DROP INDEX transactions_type_group_asc_sequence; | ||
DROP INDEX transactions_vendor_field_asc_sequence; | ||
DROP INDEX transactions_version_asc_sequence; | ||
DROP INDEX blocks_number_of_transactions; | ||
DROP INDEX blocks_reward; | ||
DROP INDEX blocks_total_amount; | ||
DROP INDEX blocks_total_fee; | ||
DROP INDEX blocks_version; | ||
`); | ||
} | ||
} |