chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit c79224cf7b70f6c0c586045ea58784a0b4507d72
parent 0e65dc1ef421f0192119ccfeb647efd30966c4d4
Author: nolash <dev@holbrook.no>
Date:   Tue, 23 Feb 2021 06:26:15 +0100

Add sqlalchemy migrations

Diffstat:
MMANIFEST.in | 2+-
Achainsyncer/db/migrations/sqlalchemy.py | 36++++++++++++++++++++++++++++++++++++
Msetup.cfg | 6++++++
3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/MANIFEST.in b/MANIFEST.in @@ -1 +1 @@ -include requirements.txt LICENSE.txt +include requirements.txt LICENSE.txt sql/**/* diff --git a/chainsyncer/db/migrations/sqlalchemy.py b/chainsyncer/db/migrations/sqlalchemy.py @@ -0,0 +1,36 @@ +from alembic import op +import sqlalchemy as sa + +def chainsyncer_upgrade(major, minor, patch): + r0_0_1_u() + +def chainsyncer_downgrade(major, minor, patch): + r0_0_1_d() + +def r0_0_1_u(): + op.create_table( + 'chain_sync', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('blockchain', sa.String, nullable=False, unique=True), + sa.Column('block_start', sa.Integer, nullable=False, default=0), + sa.Column('tx_start', sa.Integer, nullable=False, default=0), + sa.Column('block_cursor', sa.Integer, nullable=False, default=0), + sa.Column('tx_cursor', sa.Integer, nullable=False, default=0), + sa.Column('block_target', sa.Integer, nullable=True), + sa.Column('date_created', sa.DateTime, nullable=False), + sa.Column('date_updated', sa.DateTime), + ) + + op.create_table( + 'chain_sync_filter', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('chain_sync_id', sa.Integer, sa.ForeignKey('chain_sync.id'), nullable=True), + sa.Column('flags', sa.BLOB, nullable=True), + sa.Column('flags_start', sa.BLOB, nullable=True), + sa.Column('count', sa.Integer, nullable=False, default=0), + sa.Column('digest', sa.BLOB, nullable=False), + ) + +def r0_0_1_d(): + op.drop_table('chain_sync_filter') + op.drop_table('chain_sync') diff --git a/setup.cfg b/setup.cfg @@ -21,13 +21,19 @@ licence_files = LICENSE.txt [options] +include_package_data = True python_requires = >= 3.6 packages = chainsyncer chainsyncer.db + chainsyncer.db.migrations chainsyncer.db.models chainsyncer.runnable +[options.package_data] +* = + sql/* + #[options.entry_points] #console_scripts = # blocksync-celery = chainsyncer.runnable.tracker:main