"""Create blocks, transactions, inputs, outputs 

Revision ID: 14fbd693ba5b
Revises: 4e98b1435763
Create Date: 2014-12-10 13:26:26.258741

"""

# revision identifiers, used by Alembic.
revision = '14fbd693ba5b'
down_revision = '4e98b1435763'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('outputs',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('dstAddress', sa.String(length=36), nullable=True),
    sa.Column('value', sa.BigInteger(), nullable=True),
    sa.Column('txHash', sa.String(length=64), nullable=True),
    sa.Column('offset', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('txHash_2', 'outputs', ['txHash', 'offset'], unique=False)
    op.create_table('blocks',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('hash', sa.String(length=64), nullable=True),
    sa.Column('time', sa.BigInteger(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('inputs',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('txHash', sa.String(length=64), nullable=True),
    sa.Column('outputHash', sa.String(length=64), nullable=True),
    sa.Column('outputN', sa.Integer(), nullable=True),
    sa.Column('offset', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('transactions',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('hash', sa.String(length=64), nullable=True),
    sa.Column('blockID', sa.BigInteger(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('transactions')
    op.drop_table('inputs')
    op.drop_table('blocks')
    op.drop_index('txHash_2', table_name='outputs')
    op.drop_table('outputs')
    ### end Alembic commands ###
