Skip to content

Commit

Permalink
Merge pull request #125 from migalabs/fix/t_withdrawals-contains-only…
Browse files Browse the repository at this point in the history
…-one-withdrawal-per-slot

change t_withdrawals to order by index
  • Loading branch information
santi1234567 committed Jul 29, 2024
2 parents c8c3faf + 41a91fe commit e05673a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/db/migrations/000008_modify_order_by_withdrawals.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Create new table with desired order by
CREATE TABLE new_t_withdrawals(
f_slot UInt64,
f_index UInt64,
f_val_idx UInt64,
f_address TEXT,
f_amount UInt64)
ENGINE = ReplacingMergeTree()
ORDER BY (f_slot);

-- Populate new table
INSERT INTO new_t_withdrawals
SELECT * FROM t_withdrawals;

-- Rename tables
RENAME TABLE t_withdrawals TO t_withdrawals_old;
RENAME TABLE new_t_withdrawals TO t_withdrawals;

-- Drop temporary table
DROP TABLE t_withdrawals_old;
20 changes: 20 additions & 0 deletions pkg/db/migrations/000008_modify_order_by_withdrawals.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Create new table with desired order by
CREATE TABLE new_t_withdrawals(
f_slot UInt64,
f_index UInt64,
f_val_idx UInt64,
f_address TEXT,
f_amount UInt64)
ENGINE = ReplacingMergeTree()
ORDER BY (f_index);

-- Populate new table
INSERT INTO new_t_withdrawals
SELECT * FROM t_withdrawals;

-- Rename tables
RENAME TABLE t_withdrawals TO t_withdrawals_old;
RENAME TABLE new_t_withdrawals TO t_withdrawals;

-- Drop temporary table
DROP TABLE t_withdrawals_old;

0 comments on commit e05673a

Please sign in to comment.