You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1019 B

  1. CREATE TYPE block_event_type AS ENUM ('begin_block', 'end_block', '');
  2. CREATE TABLE block_events (
  3. id SERIAL PRIMARY KEY,
  4. key VARCHAR NOT NULL,
  5. value VARCHAR NOT NULL,
  6. height INTEGER NOT NULL,
  7. type block_event_type,
  8. created_at TIMESTAMPTZ NOT NULL,
  9. chain_id VARCHAR NOT NULL,
  10. UNIQUE (key, height)
  11. );
  12. CREATE TABLE tx_results (
  13. id SERIAL PRIMARY KEY,
  14. tx_result BYTEA NOT NULL,
  15. created_at TIMESTAMPTZ NOT NULL,
  16. UNIQUE (tx_result)
  17. );
  18. CREATE TABLE tx_events (
  19. id SERIAL PRIMARY KEY,
  20. key VARCHAR NOT NULL,
  21. value VARCHAR NOT NULL,
  22. height INTEGER NOT NULL,
  23. hash VARCHAR NOT NULL,
  24. tx_result_id SERIAL,
  25. created_at TIMESTAMPTZ NOT NULL,
  26. chain_id VARCHAR NOT NULL,
  27. UNIQUE (hash, key),
  28. FOREIGN KEY (tx_result_id) REFERENCES tx_results(id) ON DELETE CASCADE
  29. );
  30. CREATE INDEX idx_block_events_key_value ON block_events(key, value);
  31. CREATE INDEX idx_tx_events_key_value ON tx_events(key, value);
  32. CREATE INDEX idx_tx_events_hash ON tx_events(hash);