-
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.
- Loading branch information
Showing
24 changed files
with
397 additions
and
307 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.env | ||
.env* | ||
!.env.example | ||
mounts/ | ||
node_modules | ||
lib | ||
|
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
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,25 @@ | ||
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm'; | ||
|
||
export class NewBackfillTables1705420603000 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(` | ||
ALTER TABLE ${schema}.events_backfill RENAME TO backfill_events; | ||
CREATE TABLE ${schema}.backfill_blocks ( | ||
block_number BIGINT NOT NULL, | ||
PRIMARY KEY (block_number) | ||
); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(` | ||
DROP TABLE ${schema}.backfill_blocks; | ||
ALTER TABLE ${schema}.backfill_events RENAME TO events_backfill; | ||
`); | ||
} | ||
} |
118 changes: 45 additions & 73 deletions
118
migrations/ethereum/1615870349094-AddV4CancelAndMultiplexEvents.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 |
---|---|---|
@@ -1,81 +1,53 @@ | ||
import { MigrationInterface, QueryRunner, Table } from 'typeorm'; | ||
|
||
const eventsV4CancelEvents = new Table({ | ||
name: 'events.v4_cancel_events', | ||
columns: [ | ||
{ name: 'observed_timestamp', type: 'bigint' }, | ||
{ name: 'contract_address', type: 'varchar' }, | ||
{ name: 'transaction_hash', type: 'varchar', isPrimary: true }, | ||
{ name: 'transaction_index', type: 'bigint' }, | ||
{ name: 'log_index', type: 'bigint', isPrimary: true }, | ||
{ name: 'block_hash', type: 'varchar' }, | ||
{ name: 'block_number', type: 'bigint' }, | ||
|
||
{ name: 'maker', type: 'varchar' }, | ||
{ name: 'order_hash', type: 'varchar' }, | ||
], | ||
}); | ||
|
||
const eventsExpiredRfqOrderEvents = new Table({ | ||
name: 'events.expired_rfq_order_events', | ||
columns: [ | ||
{ name: 'observed_timestamp', type: 'bigint' }, | ||
{ name: 'contract_address', type: 'varchar' }, | ||
{ name: 'transaction_hash', type: 'varchar', isPrimary: true }, | ||
{ name: 'transaction_index', type: 'bigint' }, | ||
{ name: 'log_index', type: 'bigint', isPrimary: true }, | ||
{ name: 'block_hash', type: 'varchar' }, | ||
{ name: 'block_number', type: 'bigint' }, | ||
|
||
{ name: 'maker', type: 'varchar' }, | ||
{ name: 'order_hash', type: 'varchar' }, | ||
{ name: 'expiry', type: 'numeric' }, | ||
], | ||
}); | ||
|
||
const indexQuery = ` | ||
CREATE INDEX v4_cancel_events_transaction_hash_index | ||
ON events.v4_cancel_events (transaction_hash); | ||
CREATE INDEX v4_cancel_events_block_number_index | ||
ON events.v4_cancel_events (block_number); | ||
CREATE INDEX v4_cancel_events_maker_index | ||
ON events.v4_cancel_events (maker); | ||
CREATE INDEX v4_cancel_events_order_hash_index | ||
ON events.v4_cancel_events (order_hash); | ||
CREATE INDEX expired_rfq_events_block_number_index | ||
ON events.expired_rfq_order_events (block_number); | ||
CREATE INDEX expired_rfq_events_transaction_hash_index | ||
ON events.expired_rfq_order_events (transaction_hash); | ||
CREATE INDEX expired_rfq_events_maker_index | ||
ON events.expired_rfq_order_events (maker); | ||
CREATE INDEX expired_rfq_events_order_hash_index | ||
ON events.v4_cancel_events (order_hash); | ||
`; | ||
|
||
const dropIndexQuery = ` | ||
DROP INDEX events.v4_cancel_events_transaction_hash_index; | ||
DROP INDEX events.v4_cancel_events_block_number_index; | ||
DROP INDEX events.v4_cancel_events_maker_index; | ||
DROP INDEX events.v4_cancel_events_order_hash_index; | ||
DROP INDEX events.expired_rfq_events_block_number_index; | ||
DROP INDEX events.expired_rfq_events_transaction_hash_index; | ||
DROP INDEX events.expired_rfq_events_maker_index; | ||
DROP INDEX events.expired_rfq_events_order_hash_index; | ||
`; | ||
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm'; | ||
|
||
export class AddV4CancelAndMultiplexEvents1615870349094 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.createTable(eventsV4CancelEvents); | ||
await queryRunner.createTable(eventsExpiredRfqOrderEvents); | ||
await queryRunner.query(indexQuery); | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(` | ||
CREATE TABLE ${schema}.v4_cancel_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, | ||
maker varchar NOT NULL, | ||
order_hash varchar NOT NULL, | ||
CONSTRAINT v4_cancel_events_pk PRIMARY KEY (transaction_hash, log_index) | ||
); | ||
CREATE INDEX v4_xancel_events_order_hash_index ON ${schema}.v4_cancel_events USING btree (order_hash); | ||
CREATE INDEX v4_cancel_events_block_number_index ON ${schema}.v4_cancel_events USING btree (block_number); | ||
CREATE INDEX v4_cancel_events_maker_index ON ${schema}.v4_cancel_events USING btree (maker); | ||
CREATE INDEX v4_cancel_events_order_hash_index ON ${schema}.v4_cancel_events USING btree (order_hash); | ||
CREATE INDEX v4_cancel_events_transaction_hash_index ON ${schema}.v4_cancel_events USING btree (transaction_hash); | ||
CREATE TABLE ${schema}.expired_rfq_order_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, | ||
maker varchar NOT NULL, | ||
order_hash varchar NOT NULL, | ||
expiry numeric NOT NULL, | ||
CONSTRAINT expired_rfq_order_events_pk PRIMARY KEY (transaction_hash, log_index) | ||
); | ||
CREATE INDEX expired_rfq_events_block_number_index ON ${schema}.expired_rfq_order_events USING btree (block_number); | ||
CREATE INDEX expired_rfq_events_maker_index ON ${schema}.expired_rfq_order_events USING btree (maker); | ||
CREATE INDEX expired_rfq_events_transaction_hash_index ON ${schema}.expired_rfq_order_events USING btree (transaction_hash); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query(dropIndexQuery); | ||
await queryRunner.dropTable(eventsExpiredRfqOrderEvents); | ||
await queryRunner.dropTable(eventsV4CancelEvents); | ||
const connection = getConnection(); | ||
const { schema } = connection.options as any; | ||
await queryRunner.query(` | ||
DROP TABLE ${schema}.v4_cancel_events; | ||
DROP TABLE ${schema}.expired_rfq_order_events; | ||
`); | ||
} | ||
} |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.