-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from migalabs/fix/t_withdrawals-contains-only…
…-one-withdrawal-per-slot change t_withdrawals to order by index
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
pkg/db/migrations/000008_modify_order_by_withdrawals.down.sql
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,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
20
pkg/db/migrations/000008_modify_order_by_withdrawals.up.sql
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,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; |