|
| 1 | +import { MigrationInterface, QueryRunner } from 'typeorm'; |
| 2 | +const createTable = ` create table events_polygon.oneinch_swapped_events |
| 3 | +( |
| 4 | + observed_timestamp bigint not null, |
| 5 | + contract_address varchar not null, |
| 6 | + transaction_hash varchar not null, |
| 7 | + transaction_index bigint not null, |
| 8 | + log_index bigint not null, |
| 9 | + block_hash varchar not null, |
| 10 | + block_number bigint not null, |
| 11 | + from_token varchar not null, |
| 12 | + to_token varchar not null, |
| 13 | + from_token_amount numeric not null, |
| 14 | + to_token_amount numeric not null, |
| 15 | + "from" varchar not null, |
| 16 | + "to" varchar, |
| 17 | + constraint "PK_0e29a12f959d1552d589f49c66c" |
| 18 | + primary key (transaction_hash, log_index) |
| 19 | +);`; |
| 20 | +const createIndexes = ` |
| 21 | +create index oneinch_swapped_events_transaction_transaction_hash_index |
| 22 | + on events_polygon.oneinch_swapped_events (transaction_hash); |
| 23 | +
|
| 24 | +create index oneinch_swapped_events_transaction_block_number_index |
| 25 | + on events_polygon.oneinch_swapped_events (block_number); |
| 26 | +
|
| 27 | +create index oneinch_swapped_events_transaction_contract_addres_index |
| 28 | + on events_polygon.oneinch_swapped_events (contract_address); |
| 29 | +`; |
| 30 | +const dropTable = `DROP TABLE events_polygon.oneinch_swapped_events;`; |
| 31 | + |
| 32 | +const dropIndexes = ` |
| 33 | + DROP INDEX events_polygon.oneinch_swapped_events_transaction_transaction_hash_index; |
| 34 | + DROP INDEX events_polygon.oneinch_swapped_events_transaction_block_number_index; |
| 35 | + DROP INDEX events_polygon.oneinch_swapped_events_transaction_contract_addres_index; |
| 36 | +`; |
| 37 | + |
| 38 | +export class CreatePolygonOneinchSwappedEventTable1622124888967 implements MigrationInterface { |
| 39 | + public async up(queryRunner: QueryRunner): Promise<any> { |
| 40 | + await queryRunner.query(createTable); |
| 41 | + await queryRunner.query(createIndexes); |
| 42 | + } |
| 43 | + |
| 44 | + public async down(queryRunner: QueryRunner): Promise<any> { |
| 45 | + await queryRunner.query(dropIndexes); |
| 46 | + await queryRunner.query(dropTable); |
| 47 | + } |
| 48 | +} |
0 commit comments