diff --git a/pkg/db/migrations/000008_modify_order_by_withdrawals.down.sql b/pkg/db/migrations/000008_modify_order_by_withdrawals.down.sql new file mode 100644 index 00000000..5189cbd9 --- /dev/null +++ b/pkg/db/migrations/000008_modify_order_by_withdrawals.down.sql @@ -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; \ No newline at end of file diff --git a/pkg/db/migrations/000008_modify_order_by_withdrawals.up.sql b/pkg/db/migrations/000008_modify_order_by_withdrawals.up.sql new file mode 100644 index 00000000..88130898 --- /dev/null +++ b/pkg/db/migrations/000008_modify_order_by_withdrawals.up.sql @@ -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; \ No newline at end of file