Skip to content

Commit

Permalink
feat(indexer/postgres): block, tx and event schemas (cosmos#21078)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc authored Jul 29, 2024
1 parent e7b6d73 commit 9b6f61e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions indexer/postgres/base_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,29 @@ const BaseSQL = `
CREATE OR REPLACE FUNCTION nanos_to_timestamptz(nanos bigint) RETURNS timestamptz AS $$
SELECT to_timestamp(nanos / 1000000000) + (nanos / 1000000000) * INTERVAL '1 microsecond'
$$ LANGUAGE SQL IMMUTABLE;
CREATE TABLE IF NOT EXISTS block
(
number BIGINT NOT NULL PRIMARY KEY,
header JSONB NULL
);
CREATE TABLE IF NOT EXISTS tx
(
id BIGSERIAL PRIMARY KEY,
block_number BIGINT NOT NULL REFERENCES block (number),
index_in_block BIGINT NOT NULL,
data JSONB NOT NULL
);
CREATE TABLE IF NOT EXISTS event
(
id BIGSERIAL PRIMARY KEY,
block_number BIGINT NOT NULL REFERENCES block (number),
tx_id BIGINT NULL REFERENCES tx (id),
msg_index BIGINT NULL,
event_index BIGINT NULL,
type TEXT NOT NULL,
data JSONB NOT NULL
);
`

0 comments on commit 9b6f61e

Please sign in to comment.