-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from cowprotocol/add_new_database
Add database setup
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM postgres | ||
ENV POSTGRES_PASSWORD=postgres | ||
ENV POSTGRES_DB=mainnet | ||
COPY ./database/01_table_creation.sql /docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DOCKER_IMAGE_NAME=test_db_image | ||
DOCKER_CONTAINER_NAME=test_db_container | ||
DB_PORT=5432 | ||
|
||
install: | ||
pip install -r requirements.txt | ||
|
||
imbalances: | ||
python -m src.imbalances_script | ||
|
||
daemon: | ||
python -m src.daemon | ||
|
||
test_db: | ||
docker build -t $(DOCKER_IMAGE_NAME) -f Dockerfile.test_db . | ||
docker run -d --name $(DOCKER_CONTAINER_NAME) -p $(DB_PORT):$(DB_PORT) $(DOCKER_IMAGE_NAME) | ||
|
||
stop_test_db: | ||
docker stop $(DOCKER_CONTAINER_NAME) || true | ||
docker rm $(DOCKER_CONTAINER_NAME) || true | ||
docker rmi $(DOCKER_IMAGE_NAME) || true | ||
|
||
.PHONY: install imbalances daemon test_db run_test_db stop_test_db clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CREATE TABLE transaction_timestamps ( | ||
tx_hash bytea PRIMARY KEY, | ||
time timestamp NOT NULL | ||
); | ||
|
||
CREATE TABLE transaction_tokens ( | ||
tx_hash bytea NOT NULL, | ||
token_address bytea NOT NULL, | ||
|
||
PRIMARY KEY (tx_hash, token_address) | ||
); | ||
|
||
CREATE TYPE PriceSource AS ENUM ('coingecko', 'moralis', 'dune', 'native'); | ||
|
||
CREATE TABLE prices ( | ||
token_address bytea NOT NULL, | ||
time timestamp NOT NULL, | ||
price numeric(60, 18) NOT NULL, | ||
source PriceSource NOT NULL, | ||
|
||
PRIMARY KEY (token_address, time, source) | ||
); | ||
|
||
CREATE TABLE token_decimals ( | ||
token_address bytea PRIMARY KEY, | ||
decimals int NOT NULL | ||
); |