moonstream/db
kompotkot 9dfe70af06 XDai database blockchain update to support XDai 2022-05-26 13:23:12 +00:00
..
alembic Difficulty big int out of range, switched to varchar 2022-05-23 13:53:34 +00:00
configs Moonstreamdb with read only 2022-03-09 11:40:34 +00:00
deploy Changed 0.0.0.0 to localhost for db server 2021-10-14 11:06:06 +00:00
moonstreamdb XDai database blockchain update to support XDai 2022-05-26 13:23:12 +00:00
scripts Add fixes remoce address_id from ethereum_labels_v2. 2021-10-19 23:59:16 +03:00
server Getting polygon_block_latest_label_moonworm_alpha for status db 2022-04-13 16:29:21 +00:00
.dockerignore Flag for db name in env generation script 2021-12-01 12:38:14 +00:00
.gitignore Updated gitignore for schematic db 2022-05-10 11:29:41 +00:00
Dockerfile Docker and docker compose setup for db and moonstream api 2021-11-30 14:29:10 +00:00
README.md
alembic.sh
migrate.sh Docker and docker compose setup for db and moonstream api 2021-11-30 14:29:10 +00:00
mypy.ini
scm.nix Removed all refs 2022-05-11 13:17:25 +00:00
setup.py Removed specific versions at setup.py 2021-11-10 18:10:38 +00:00
sync_conf.yml Schematic initial setup 2022-05-10 11:28:24 +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