diff --git a/core/store/migrate/migrations/0248_log_poller_primary_keys.sql b/core/store/migrate/migrations/0248_log_poller_primary_keys.sql index b12f2b9c143..82c6c17bc21 100644 --- a/core/store/migrate/migrations/0248_log_poller_primary_keys.sql +++ b/core/store/migrate/migrations/0248_log_poller_primary_keys.sql @@ -2,12 +2,20 @@ ALTER TABLE evm.logs DROP CONSTRAINT logs_pkey; ALTER TABLE evm.logs ADD COLUMN id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY; +CREATE UNIQUE INDEX idx_evm_logs_block_hash_log_index_evm_chain_id ON evm.logs (block_hash, log_index, evm_chain_id); ALTER TABLE evm.log_poller_blocks DROP CONSTRAINT log_poller_blocks_pkey; ALTER TABLE evm.log_poller_blocks ADD COLUMN id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY; +CREATE UNIQUE INDEX idx_evm_log_poller_blocks_block_number_evm_chain_id ON evm.log_poller_blocks (block_number, evm_chain_id); + +-- TODO: restore UNIQUE constratint on original pkey! -- +goose Down +DROP INDEX idx_evm_log_poller_blocks_block_number_evm_chain_id; ALTER TABLE evm.log_poller_blocks DROP COLUMN id; ALTER TABLE evm.log_poller_blocks ADD PRIMARY KEY (block_number, evm_chain_id); -ALTER TABLE evm.logs DROP COLUMN id; +DROP INDEX idx_evm_logs_block_hash_log_index_evm_chain_id; +dALTER TABLE evm.logs DROP COLUMN id; ALTER TABLE evm.logs ADD PRIMARY KEY (block_hash, log_index, evm_chain_id); + +