Skip to content

Commit

Permalink
Delete duplicate values (#2633)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR552 authored Oct 10, 2023
1 parent f67da72 commit 8b32a1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions db/migrations/state/0010.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
-- +migrate Up
CREATE INDEX IF NOT EXISTS l2block_block_hash_idx ON state.l2block (block_hash);

DELETE FROM state.sequences a USING (
SELECT MIN(ctid) as ctid, from_batch_num
FROM state.sequences
GROUP BY from_batch_num HAVING COUNT(*) > 1
) b
WHERE a.from_batch_num = b.from_batch_num
AND a.ctid <> b.ctid;

ALTER TABLE state.sequences ADD PRIMARY KEY(from_batch_num);
ALTER TABLE state.trusted_reorg ADD PRIMARY KEY(timestamp);
ALTER TABLE state.sync_info ADD PRIMARY KEY(last_batch_num_seen, last_batch_num_consolidated, init_sync_batch);
Expand Down

0 comments on commit 8b32a1e

Please sign in to comment.