diff --git a/bridge-history-api/internal/orm/batch_event.go b/bridge-history-api/internal/orm/batch_event.go index 931a5ad718..76ed47ce3b 100644 --- a/bridge-history-api/internal/orm/batch_event.go +++ b/bridge-history-api/internal/orm/batch_event.go @@ -47,7 +47,7 @@ type BatchEvent struct { // TableName returns the table name for the BatchEvent model. func (*BatchEvent) TableName() string { - return "batch_event" + return "batch_event_v2" } // NewBatchEvent returns a new instance of BatchEvent. diff --git a/bridge-history-api/internal/orm/cross_message.go b/bridge-history-api/internal/orm/cross_message.go index 493279e6e9..56626b17fa 100644 --- a/bridge-history-api/internal/orm/cross_message.go +++ b/bridge-history-api/internal/orm/cross_message.go @@ -124,7 +124,7 @@ type CrossMessage struct { // TableName returns the table name for the CrossMessage model. func (*CrossMessage) TableName() string { - return "cross_message" + return "cross_message_v2" } // NewCrossMessage returns a new instance of CrossMessage. diff --git a/bridge-history-api/internal/orm/migrate/migrations/00001_cross_message.sql b/bridge-history-api/internal/orm/migrate/migrations/00001_cross_message_v2.sql similarity index 74% rename from bridge-history-api/internal/orm/migrate/migrations/00001_cross_message.sql rename to bridge-history-api/internal/orm/migrate/migrations/00001_cross_message_v2.sql index 477138babb..6ec6536def 100644 --- a/bridge-history-api/internal/orm/migrate/migrations/00001_cross_message.sql +++ b/bridge-history-api/internal/orm/migrate/migrations/00001_cross_message_v2.sql @@ -1,6 +1,6 @@ -- +goose Up -- +goose StatementBegin -CREATE TABLE cross_message +CREATE TABLE cross_message_v2 ( id BIGSERIAL PRIMARY KEY, message_type SMALLINT NOT NULL, @@ -38,20 +38,20 @@ CREATE TABLE cross_message deleted_at TIMESTAMP(0) DEFAULT NULL ); -CREATE UNIQUE INDEX IF NOT EXISTS idx_cm_message_hash ON cross_message (message_hash); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_l1_block_number ON cross_message (message_type, l1_block_number DESC); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_l2_block_number ON cross_message (message_type, l2_block_number DESC); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_rollup_status_message_nonce ON cross_message (message_type, rollup_status, message_nonce DESC); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_message_nonce_tx_status_l2_block_number ON cross_message (message_type, message_nonce, tx_status, l2_block_number); -CREATE INDEX IF NOT EXISTS idx_cm_l1_tx_hash ON cross_message (l1_tx_hash); -CREATE INDEX IF NOT EXISTS idx_cm_l2_tx_hash ON cross_message (l2_tx_hash); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_tx_status_sender_block_timestamp ON cross_message (message_type, tx_status, sender, block_timestamp DESC); -CREATE INDEX IF NOT EXISTS idx_cm_message_type_sender_block_timestamp ON cross_message (message_type, sender, block_timestamp DESC); -CREATE INDEX IF NOT EXISTS idx_cm_sender_block_timestamp ON cross_message (sender, block_timestamp DESC); +CREATE UNIQUE INDEX IF NOT EXISTS idx_cm_message_hash ON cross_message_v2 (message_hash); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_l1_block_number ON cross_message_v2 (message_type, l1_block_number DESC); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_l2_block_number ON cross_message_v2 (message_type, l2_block_number DESC); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_rollup_status_message_nonce ON cross_message_v2 (message_type, rollup_status, message_nonce DESC); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_message_nonce_tx_status_l2_block_number ON cross_message_v2 (message_type, message_nonce, tx_status, l2_block_number); +CREATE INDEX IF NOT EXISTS idx_cm_l1_tx_hash ON cross_message_v2 (l1_tx_hash); +CREATE INDEX IF NOT EXISTS idx_cm_l2_tx_hash ON cross_message_v2 (l2_tx_hash); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_tx_status_sender_block_timestamp ON cross_message_v2 (message_type, tx_status, sender, block_timestamp DESC); +CREATE INDEX IF NOT EXISTS idx_cm_message_type_sender_block_timestamp ON cross_message_v2 (message_type, sender, block_timestamp DESC); +CREATE INDEX IF NOT EXISTS idx_cm_sender_block_timestamp ON cross_message_v2 (sender, block_timestamp DESC); -- +goose StatementEnd -- +goose Down -- +goose StatementBegin -DROP TABLE IF EXISTS cross_message; +DROP TABLE IF EXISTS cross_message_v2; -- +goose StatementEnd diff --git a/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event.sql b/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql similarity index 74% rename from bridge-history-api/internal/orm/migrate/migrations/00002_batch_event.sql rename to bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql index 1f56d55cd1..ba42500f32 100644 --- a/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event.sql +++ b/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql @@ -1,6 +1,6 @@ -- +goose Up -- +goose StatementBegin -CREATE TABLE batch_event +CREATE TABLE batch_event_v2 ( id BIGSERIAL PRIMARY KEY, l1_block_number BIGINT NOT NULL, @@ -15,14 +15,14 @@ CREATE TABLE batch_event deleted_at TIMESTAMP(0) DEFAULT NULL ); -CREATE INDEX IF NOT EXISTS idx_be_l1_block_number ON batch_event (l1_block_number); -CREATE INDEX IF NOT EXISTS idx_be_batch_index ON batch_event (batch_index); -CREATE INDEX IF NOT EXISTS idx_be_batch_index_batch_hash ON batch_event (batch_index, batch_hash); -CREATE INDEX IF NOT EXISTS idx_be_end_block_number_update_status_batch_status_batch_index ON batch_event (end_block_number, update_status, batch_status, batch_index); +CREATE INDEX IF NOT EXISTS idx_be_l1_block_number ON batch_event_v2 (l1_block_number); +CREATE INDEX IF NOT EXISTS idx_be_batch_index ON batch_event_v2 (batch_index); +CREATE INDEX IF NOT EXISTS idx_be_batch_index_batch_hash ON batch_event_v2 (batch_index, batch_hash); +CREATE INDEX IF NOT EXISTS idx_be_end_block_number_update_status_batch_status_batch_index ON batch_event_v2 (end_block_number, update_status, batch_status, batch_index); -- +goose StatementEnd -- +goose Down -- +goose StatementBegin -DROP TABLE IF EXISTS batch_event; +DROP TABLE IF EXISTS batch_event_v2; -- +goose StatementEnd \ No newline at end of file