From 08925ffc8815d9613a69204a74c85d168f8a8305 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Tue, 2 Jul 2024 12:37:07 -0700 Subject: [PATCH] fix(plugin-persistence-ethereum): make created_at TIMESTAMPTZ in schema 1. The problem was that the database schema was defined in a way that was destroying timestamp information during insertion of records. 2. Updating the schema to hold the timestamp information made the test pass. More information about why it's recommended to store datetime data with the TIMESTAMPTZ column type is explained by the author of the node-postgres library which is an important part of the problem (it assumes local time for columns that do not store the timestamp time zone). https://node-postgres.com/features/types#date--timestamp--timestamptz Fixes #3373 Signed-off-by: Peter Somogyvari --- .../src/main/sql/schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cactus-plugin-persistence-ethereum/src/main/sql/schema.sql b/packages/cactus-plugin-persistence-ethereum/src/main/sql/schema.sql index f57f7b4ab0..0fd05994f3 100644 --- a/packages/cactus-plugin-persistence-ethereum/src/main/sql/schema.sql +++ b/packages/cactus-plugin-persistence-ethereum/src/main/sql/schema.sql @@ -39,10 +39,10 @@ GRANT ALL ON TABLE public.plugin_status TO service_role; CREATE TABLE IF NOT EXISTS public.block ( "number" numeric NOT NULL, - created_at timestamp without time zone NOT NULL, + created_at timestamptz NOT NULL, hash text COLLATE pg_catalog."default" NOT NULL, number_of_tx numeric NOT NULL, - sync_at timestamp with time zone NOT NULL DEFAULT now(), + sync_at timestamptz NOT NULL DEFAULT now(), CONSTRAINT block_pkey PRIMARY KEY ("number"), CONSTRAINT block_hash_key UNIQUE (hash), CONSTRAINT block_number_key UNIQUE ("number")