-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds migration to create Celo Wrap/Unrwap table for consistency.
- Loading branch information
Andrés Elizondo
committed
Dec 15, 2023
1 parent
be1de3f
commit fe11294
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
migrations/celo/1702673081360-CreateWrapUnwrapNativeEventsTable.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,46 @@ | ||
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm'; | ||
|
||
export class CreateCeloWrapNativeEventsTable1702673081360 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(` | ||
CREATE TABLE ${schema}.wrap_native_events ( | ||
observed_timestamp int8 NOT NULL, | ||
contract_address varchar NOT NULL, | ||
transaction_hash varchar NOT NULL, | ||
transaction_index int8 NOT NULL, | ||
log_index int8 NOT NULL, | ||
block_hash varchar NOT NULL, | ||
block_number int8 NOT NULL, | ||
dst varchar NOT NULL, | ||
wad numeric NOT NULL, | ||
PRIMARY KEY (transaction_hash, log_index) | ||
); | ||
CREATE INDEX wrap_native_events_block_number_index ON ${schema}.wrap_native_events USING btree (block_number); | ||
CREATE INDEX wrap_native_events_transaction_hash_index ON ${schema}.wrap_native_events USING btree (transaction_hash); | ||
CREATE TABLE ${schema}.unwrap_native_events ( | ||
observed_timestamp int8 NOT NULL, | ||
contract_address varchar NOT NULL, | ||
transaction_hash varchar NOT NULL, | ||
transaction_index int8 NOT NULL, | ||
log_index int8 NOT NULL, | ||
block_hash varchar NOT NULL, | ||
block_number int8 NOT NULL, | ||
src varchar NOT NULL, | ||
wad numeric NOT NULL, | ||
PRIMARY KEY (transaction_hash, log_index) | ||
); | ||
CREATE INDEX unwrap_native_events_block_number_index ON ${schema}.unwrap_native_events USING btree (block_number); | ||
CREATE INDEX unwrap_native_events_transaction_hash_index ON ${schema}.unwrap_native_events USING btree (transaction_hash); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(`DROP TABLE ${schema}.wrap_native_events;`); | ||
await queryRunner.query(`DROP TABLE ${schema}.unwrap_native_events;`); | ||
} | ||
} |