Skip to content

Commit

Permalink
fix(plugin-persistence-ethereum): make created_at TIMESTAMPTZ in schema
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
petermetz committed Jul 3, 2024
1 parent d14bf02 commit 08925ff
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 08925ff

Please sign in to comment.