Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
46 lines
1.3 KiB
SQL
46 lines
1.3 KiB
SQL
CREATE TABLE tx (
|
|
hash CHAR(64) NOT NULL,
|
|
"index" BIGINT NOT NULL,
|
|
height BIGINT NOT NULL,
|
|
block_time TIMESTAMP NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT tx_pk PRIMARY KEY (hash)
|
|
);
|
|
|
|
CREATE INDEX tx_height_idx ON tx (height);
|
|
|
|
CREATE SEQUENCE event_id_seq AS INTEGER;
|
|
|
|
CREATE TABLE event (
|
|
id INTEGER NOT NULL DEFAULT nextval('event_id_seq'),
|
|
tx_hash CHAR(64) NOT NULL,
|
|
"type" VARCHAR NOT NULL,
|
|
"index" SMALLINT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT event_pk PRIMARY KEY (id),
|
|
CONSTRAINT event_tx_fk FOREIGN KEY (tx_hash) REFERENCES tx (hash) ON DELETE CASCADE
|
|
);
|
|
|
|
ALTER SEQUENCE event_id_seq OWNED BY event.id;
|
|
|
|
CREATE INDEX event_type_idx ON event ("type");
|
|
|
|
CREATE TABLE attribute (
|
|
event_id INTEGER NOT NULL,
|
|
name VARCHAR NOT NULL,
|
|
value JSONB NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT attribute_pk PRIMARY KEY (event_id, name),
|
|
CONSTRAINT attribute_event_fk FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE raw_tx (
|
|
hash CHAR(64) NOT NULL,
|
|
data TEXT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT raw_tx_pk PRIMARY KEY (hash)
|
|
);
|