moonstream/db
kompotkot d50a9dd60c HOME path missing when building with go deployment script 2021-09-09 15:34:47 +00:00
..
alembic Adds foreign key constraint to ethereum_labels.transaction_hash 2021-09-02 23:02:02 -07:00
deploy HOME path missing when building with go deployment script 2021-09-09 15:34:47 +00:00
moonstreamdb Bumped moonstreamdb version to 0.1.0 2021-09-02 23:04:23 -07:00
server Removed executable file 2021-09-07 16:27:44 +00:00
.gitignore Fixes for transactions writing to db 2021-07-29 01:49:31 +03:00
README.md Documentation for moonstreamdb package 2021-07-27 01:05:10 -07:00
alembic.sample.ini Added Ethereum Signature Database tables to database 2021-07-27 00:06:23 -07:00
alembic.sh Typo in import in moonstreamdb mmodule 2021-07-27 21:22:14 +00:00
mypy.ini Added EthereumSmartContract model to database 2021-07-28 20:58:56 -07:00
sample.env Merge branch 'main' into smart-contract-crawlers 2021-07-28 10:34:55 -07:00
setup.py Added cli for db and fixed error in labels model 2021-08-09 14:58:48 +00:00

README.md

moonstream db

Setting up moonstreamdb

Copy sample.env to a new file and set the environment variables to appropriate values. This new file should be sourced every time you want to access the database with the moonstreamdb application or any dependents.

To be able to run migrations, copy alembic.sample.ini to a separate file (e.g. ./secrets/alembic.dev.ini) and modify the sqlalchemy.url setting in the new file to point at your database.

Make sure your database is at the latest alembic migration:

alembic -c ./secrets/alembic.dev.ini upgrade head

Adding a new table to database

Add SQLAlchemy model in moonstreamdb/models.py

Import new model and add tablename to whitelist in alembic/env.py

Create a migration:

alembic -c <alembic config file> revision -m "<revision message>" --autogenerate

Always check the autogenerated file to make sure that it isn't performing any actions that you don't want it to. A good policy is to delete any operations that don't touch the tables that you created.

Then run the migration:

alembic -c <alembic config file> upgrade head