Skip to content

Commit

Permalink
fix initdb
Browse files Browse the repository at this point in the history
  • Loading branch information
mihanixa1 committed Apr 26, 2024
1 parent 71a6b9f commit 13c39d2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ services:
env_file:
- ./docker/postgres/dev.env
- ./docker/pg_root_publiser
networks:
- backend
49 changes: 29 additions & 20 deletions docker/postgres/initdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ create extension if not exists citext;

create table public.interaction (
id integer primary key generated by default as identity,
interaction_hash varchar(66) not null,
interaction_hash varchar(66) unique not null,
chain_id bigint,
selector varchar(6),
tx_to varchar(42)
tx_to varchar(42),
unique (chain_id, tx_to, selector)
);

create table public.interaction_approve (
Expand All @@ -15,16 +16,18 @@ create table public.interaction_approve (
public.interaction(interaction_hash) on delete cascade,
eth_address varchar(42) not null,
message_ citext,
signature_hex citext
signature_hex citext,
unique (interaction_hash, eth_address)
);

create table public.interaction_tx (
id integer primary key generated by default as identity,
id bigint primary key generated by default as identity,
interaction_hash varchar(66) not null references
public.interaction(interaction_hash) on delete cascade,
eth_address varchar(42) not null,
tx_hash varchar(66) not null,
block_id bigint not null
block_id bigint not null,
unique (interaction_hash, tx_hash)
);

create table public.moralis_scan_checkpoints (
Expand All @@ -33,23 +36,29 @@ create table public.moralis_scan_checkpoints (
public.interaction(interaction_hash) on delete cascade,
eth_address varchar(42) not null,
block_id bigint not null
)

alter table only public.interaction
add constraint interaction_uix unique(chainid, tx_to, selector);

alter table only public.interaction_approve
add constraint interaction_approve_approve_uix unique(interaction_hash, eth_address);

alter table only public.interaction_tx
add constraint interaction_tx_uix unique(interaction_hash, tx_hash);
);

create index interaction_approve_interaction_hash_index on public.interaction_approve using hash(interaction_hash);
create index interaction_approve_interaction_hash_index
on public.interaction_approve
using hash (interaction_hash)
;

create index interaction_approve_eth_address_index on public.interaction_approve using hash(eth_address);
create index interaction_approve_eth_address_index
on public.interaction_approve
using hash (eth_address)
;

create index interaction_tx_interaction_hash_index on public.interaction_tx using hash(interaction_hash);
create index interaction_tx_interaction_hash_index
on public.interaction_tx
using hash (interaction_hash)
;

create index interaction_tx_eth_address_index on public.interaction_tx using hash(eth_address);
create index interaction_tx_eth_address_index
on public.interaction_tx
using hash (eth_address)
;

create index interaction_tx_block_id on public.interaction_tx using btree(block_id);
create index interaction_tx_block_id
on public.interaction_tx
using btree (block_id)
;

0 comments on commit 13c39d2

Please sign in to comment.