kopia lustrzana https://github.com/bugout-dev/moonstream
135 wiersze
9.2 KiB
Python
135 wiersze
9.2 KiB
Python
"""Inital migration
|
|
|
|
Revision ID: 21cced47077c
|
|
Revises:
|
|
Create Date: 2021-07-29 20:30:25.863724
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '21cced47077c'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('esd_event_signatures',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('text_signature', sa.Text(), nullable=False),
|
|
sa.Column('hex_signature', sa.VARCHAR(length=66), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_esd_event_signatures'))
|
|
)
|
|
op.create_index(op.f('ix_esd_event_signatures_id'), 'esd_event_signatures', ['id'], unique=True)
|
|
op.create_table('esd_function_signatures',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('text_signature', sa.Text(), nullable=False),
|
|
sa.Column('hex_signature', sa.VARCHAR(length=10), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_esd_function_signatures'))
|
|
)
|
|
op.create_index(op.f('ix_esd_function_signatures_id'), 'esd_function_signatures', ['id'], unique=True)
|
|
op.create_table('ethereum_blocks',
|
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
|
sa.Column('difficulty', sa.BigInteger(), nullable=True),
|
|
sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True),
|
|
sa.Column('gas_limit', sa.BigInteger(), nullable=True),
|
|
sa.Column('gas_used', sa.BigInteger(), nullable=True),
|
|
sa.Column('hash', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True),
|
|
sa.Column('miner', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('uncles', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('size', sa.Integer(), nullable=True),
|
|
sa.Column('state_root', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('timestamp', sa.BigInteger(), nullable=True),
|
|
sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
|
sa.PrimaryKeyConstraint('block_number', name=op.f('pk_ethereum_blocks'))
|
|
)
|
|
op.create_index(op.f('ix_ethereum_blocks_block_number'), 'ethereum_blocks', ['block_number'], unique=True)
|
|
op.create_index(op.f('ix_ethereum_blocks_hash'), 'ethereum_blocks', ['hash'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_blocks_timestamp'), 'ethereum_blocks', ['timestamp'], unique=False)
|
|
op.create_table('ethereum_pending_transactions',
|
|
sa.Column('hash', sa.VARCHAR(length=256), nullable=False),
|
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
|
sa.Column('from_address', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('to_address', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('input', sa.Text(), nullable=True),
|
|
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('transaction_index', sa.BigInteger(), nullable=True),
|
|
sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
|
sa.ForeignKeyConstraint(['block_number'], ['ethereum_blocks.block_number'], name=op.f('fk_ethereum_pending_transactions_block_number_ethereum_blocks'), ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('hash', name=op.f('pk_ethereum_pending_transactions'))
|
|
)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_block_number'), 'ethereum_pending_transactions', ['block_number'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_from_address'), 'ethereum_pending_transactions', ['from_address'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_gas'), 'ethereum_pending_transactions', ['gas'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_gas_price'), 'ethereum_pending_transactions', ['gas_price'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_hash'), 'ethereum_pending_transactions', ['hash'], unique=True)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_to_address'), 'ethereum_pending_transactions', ['to_address'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_pending_transactions_value'), 'ethereum_pending_transactions', ['value'], unique=False)
|
|
op.create_table('ethereum_transactions',
|
|
sa.Column('hash', sa.VARCHAR(length=256), nullable=False),
|
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
|
sa.Column('from_address', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('to_address', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('input', sa.Text(), nullable=True),
|
|
sa.Column('nonce', sa.VARCHAR(length=256), nullable=True),
|
|
sa.Column('transaction_index', sa.BigInteger(), nullable=True),
|
|
sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True),
|
|
sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
|
sa.ForeignKeyConstraint(['block_number'], ['ethereum_blocks.block_number'], name=op.f('fk_ethereum_transactions_block_number_ethereum_blocks'), ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('hash', name=op.f('pk_ethereum_transactions'))
|
|
)
|
|
op.create_index(op.f('ix_ethereum_transactions_block_number'), 'ethereum_transactions', ['block_number'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_transactions_from_address'), 'ethereum_transactions', ['from_address'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_transactions_gas'), 'ethereum_transactions', ['gas'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_transactions_gas_price'), 'ethereum_transactions', ['gas_price'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_transactions_hash'), 'ethereum_transactions', ['hash'], unique=True)
|
|
op.create_index(op.f('ix_ethereum_transactions_to_address'), 'ethereum_transactions', ['to_address'], unique=False)
|
|
op.create_index(op.f('ix_ethereum_transactions_value'), 'ethereum_transactions', ['value'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_ethereum_transactions_value'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_to_address'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_hash'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_gas_price'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_gas'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_from_address'), table_name='ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_transactions_block_number'), table_name='ethereum_transactions')
|
|
op.drop_table('ethereum_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_value'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_to_address'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_hash'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_gas_price'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_gas'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_from_address'), table_name='ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_pending_transactions_block_number'), table_name='ethereum_pending_transactions')
|
|
op.drop_table('ethereum_pending_transactions')
|
|
op.drop_index(op.f('ix_ethereum_blocks_timestamp'), table_name='ethereum_blocks')
|
|
op.drop_index(op.f('ix_ethereum_blocks_hash'), table_name='ethereum_blocks')
|
|
op.drop_index(op.f('ix_ethereum_blocks_block_number'), table_name='ethereum_blocks')
|
|
op.drop_table('ethereum_blocks')
|
|
op.drop_index(op.f('ix_esd_function_signatures_id'), table_name='esd_function_signatures')
|
|
op.drop_table('esd_function_signatures')
|
|
op.drop_index(op.f('ix_esd_event_signatures_id'), table_name='esd_event_signatures')
|
|
op.drop_table('esd_event_signatures')
|
|
# ### end Alembic commands ###
|