From 5fc312ce5a29639869a2bc0ccf09c76c367a9a35 Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Fri, 27 Oct 2023 13:00:11 +0200 Subject: [PATCH] Loading random data to the db --- .../migrations/0199_load_data_for_test.sql | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 core/store/migrate/migrations/0199_load_data_for_test.sql diff --git a/core/store/migrate/migrations/0199_load_data_for_test.sql b/core/store/migrate/migrations/0199_load_data_for_test.sql new file mode 100644 index 0000000000..e6607e1969 --- /dev/null +++ b/core/store/migrate/migrations/0199_load_data_for_test.sql @@ -0,0 +1,71 @@ +-- +goose Up + +CREATE EXTENSION pgcrypto; + +INSERT INTO evm.logs( + evm_chain_id, + log_index, + block_hash, + block_number, + address, + event_sig, + topics, + tx_hash, + data, + created_at, + block_timestamp +) +SELECT + 1337 AS evm_chain_id, + gs AS log_index, + rb1 AS block_hash, + gs AS block_number, + rb2 AS address, + rb1 AS event_sig, + ARRAY[rb1, rb2, rb1, rb2] AS topics, + rb1 AS tx_hash, + gen_random_bytes(128) AS data, + timestamp '2023-01-01 00:00:00' + random() * (timestamp '2023-12-31 23:59:59' - timestamp '2023-01-01 00:00:00') AS created_at, + timestamp '2023-01-01 00:00:00' + random() * (timestamp '2023-12-31 23:59:59' - timestamp '2023-01-01 00:00:00') AS block_timestamp +FROM generate_series(1, 200000) gs + LEFT JOIN LATERAL ( + SELECT gen_random_bytes(32) AS rb1, + gen_random_bytes(32) as rb2) as foo ON true; + + +INSERT INTO evm.logs( + evm_chain_id, + log_index, + block_hash, + block_number, + address, + event_sig, + topics, + tx_hash, + data, + created_at, + block_timestamp +) +SELECT + 2337 AS evm_chain_id, + gs AS log_index, + rb1 AS block_hash, + gs AS block_number, + rb2 AS address, + rb1 AS event_sig, + ARRAY[rb1, rb2, rb1, rb2] AS topics, + rb1 AS tx_hash, + gen_random_bytes(128) AS data, + timestamp '2023-01-01 00:00:00' + random() * (timestamp '2023-12-31 23:59:59' - timestamp '2023-01-01 00:00:00') AS created_at, + timestamp '2023-01-01 00:00:00' + random() * (timestamp '2023-12-31 23:59:59' - timestamp '2023-01-01 00:00:00') AS block_timestamp +FROM generate_series(1, 200000) gs + LEFT JOIN LATERAL ( + SELECT gen_random_bytes(32) AS rb1, + gen_random_bytes(32) as rb2) as foo ON true; + +DROP EXTENSION pgcrypto; + +-- +goose Down + +delete from evm.logs where evm_chain_id = 1337; +delete from evm.logs where evm_chain_id = 2337; \ No newline at end of file