Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor tweaks to the database schema #202

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sql/01_tables_graph_database.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE networks
(
id UUID PRIMARY KEY,
chain_id NUMERIC NOT NULL UNIQUE,
chain_id BIGINT NOT NULL UNIQUE,
name TEXT NOT NULL,
description TEXT NOT NULL,
symbol VARCHAR(16) NOT NULL
Expand All @@ -20,7 +20,7 @@ CREATE TABLE collections
id UUID PRIMARY KEY,
network_id UUID NOT NULL REFERENCES networks ON DELETE CASCADE,
contract_address VARCHAR(128) NOT NULL,
start_height NUMERIC NOT NULL,
start_height BIGINT NOT NULL,
name TEXT NOT NULL,
description TEXT NOT NULL,
symbol VARCHAR(16) NOT NULL,
Expand Down Expand Up @@ -86,7 +86,7 @@ CREATE TABLE networks_marketplaces
network_id UUID NOT NULL REFERENCES networks ON DELETE CASCADE,
marketplace_id UUID NOT NULL REFERENCES marketplaces ON DELETE CASCADE,
contract_address VARCHAR(128) NOT NULL,
start_height NUMERIC NOT NULL,
start_height BIGINT NOT NULL,
PRIMARY KEY (network_id, marketplace_id, contract_address)
);

Expand Down
10 changes: 5 additions & 5 deletions sql/02_tables_events_database.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE TABLE transfers
(
id UUID PRIMARY KEY,
chain_id NUMERIC NOT NULL,
chain_id BIGINT NOT NULL,
token_standard VARCHAR(128) NOT NULL,
collection_address VARCHAR(128) NOT NULL,
token_id VARCHAR(128) NOT NULL,
block_number NUMERIC NOT NULL,
block_number BIGINT NOT NULL,
transaction_hash VARCHAR(128) NOT NULL,
event_index INTEGER NOT NULL,
sender_address VARCHAR(128) NOT NULL,
Expand All @@ -23,11 +23,11 @@ CREATE INDEX transfers_token_id_idx ON transfers (token_id);
CREATE TABLE sales
(
id UUID PRIMARY KEY,
chain_id NUMERIC NOT NULL,
chain_id BIGINT NOT NULL,
marketplace_address VARCHAR(128) NOT NULL,
collection_address VARCHAR(128) NOT NULL,
token_id VARCHAR(128) NOT NULL,
block_number NUMERIC NOT NULL,
block_number BIGINT NOT NULL,
transaction_hash VARCHAR(128) NOT NULL,
event_index INTEGER NOT NULL,
seller_address VARCHAR(128) NOT NULL,
Expand All @@ -42,7 +42,7 @@ CREATE TABLE sales

CREATE INDEX sales_marketplace_address_idx ON sales (LOWER(marketplace_address));

CREATE INDEX sales_collection_address_idx ON sales (LOWER(collection_address));
CREATE INDEX sales_collection_address_idx ON sales (LOWER(collection_address), token_id);

CREATE INDEX sales_currency_address_idx ON sales (LOWER(currency_address));

Expand Down