Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds migration to create Celo Wrap/Unrwap table for consistency. #143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions migrations/celo/1702673081360-CreateWrapUnwrapNativeEventsTable.ts
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;`);
}
}
Loading