Add sqlalchemy migrations

This commit is contained in:
nolash 2021-02-23 06:26:15 +01:00
parent 0e65dc1ef4
commit c79224cf7b
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 43 additions and 1 deletions

View File

@ -1 +1 @@
include requirements.txt LICENSE.txt include requirements.txt LICENSE.txt sql/**/*

View File

@ -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')

View File

@ -21,13 +21,19 @@ licence_files =
LICENSE.txt LICENSE.txt
[options] [options]
include_package_data = True
python_requires = >= 3.6 python_requires = >= 3.6
packages = packages =
chainsyncer chainsyncer
chainsyncer.db chainsyncer.db
chainsyncer.db.migrations
chainsyncer.db.models chainsyncer.db.models
chainsyncer.runnable chainsyncer.runnable
[options.package_data]
* =
sql/*
#[options.entry_points] #[options.entry_points]
#console_scripts = #console_scripts =
# blocksync-celery = chainsyncer.runnable.tracker:main # blocksync-celery = chainsyncer.runnable.tracker:main