-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add database setup #74
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d188824
add file for database creation and docker file for local database
fhenneke fbced8a
add some comment on local setup of database
fhenneke a14969d
Add Makefile for easy db building
bram-vdberg 4fe802b
restructure tables
fhenneke 8f55892
fix naming
fhenneke 567fd0b
Merge branch 'main' into add_new_database
fhenneke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fhenneke Do you know if this is easy to change, in case we end up using some other price feeds as well?