"""Update TransactionAddressInfo fields to avoid confusion

Revision ID: 38bb38e30003
Revises: 4ebdf385f160
Create Date: 2014-07-09 17:32:02.560103

"""

# revision identifiers, used by Alembic.
revision = '38bb38e30003'
down_revision = '4ebdf385f160'

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('transaction_address_info', sa.Column('received_value', sa.Numeric(precision=15, scale=8), nullable=True))
    op.add_column('transaction_address_info', sa.Column('spent_value', sa.Numeric(precision=15, scale=8), nullable=True))
    op.add_column('transaction_address_info', sa.Column('vin_count', sa.Integer(), nullable=True))
    op.add_column('transaction_address_info', sa.Column('vout_count', sa.Integer(), nullable=True))
    op.create_index(op.f('ix_transaction_address_info_received_value'), 'transaction_address_info', ['received_value'], unique=False)
    op.create_index(op.f('ix_transaction_address_info_spent_value'), 'transaction_address_info', ['spent_value'], unique=False)
    op.create_index(op.f('ix_transaction_address_info_vin_count'), 'transaction_address_info', ['vin_count'], unique=False)
    op.create_index(op.f('ix_transaction_address_info_vout_count'), 'transaction_address_info', ['vout_count'], unique=False)
    op.drop_index('ix_transaction_address_info_in_count', table_name='transaction_address_info')
    op.drop_index('ix_transaction_address_info_in_value', table_name='transaction_address_info')
    op.drop_index('ix_transaction_address_info_out_count', table_name='transaction_address_info')
    op.drop_index('ix_transaction_address_info_out_value', table_name='transaction_address_info')
    op.drop_column('transaction_address_info', 'out_count')
    op.drop_column('transaction_address_info', 'in_value')
    op.drop_column('transaction_address_info', 'out_value')
    op.drop_column('transaction_address_info', 'in_count')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('transaction_address_info', sa.Column('in_count', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.add_column('transaction_address_info', sa.Column('out_value', mysql.DECIMAL(precision=15, scale=8), nullable=True))
    op.add_column('transaction_address_info', sa.Column('in_value', mysql.DECIMAL(precision=15, scale=8), nullable=True))
    op.add_column('transaction_address_info', sa.Column('out_count', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_index('ix_transaction_address_info_out_value', 'transaction_address_info', ['out_value'], unique=False)
    op.create_index('ix_transaction_address_info_out_count', 'transaction_address_info', ['out_count'], unique=False)
    op.create_index('ix_transaction_address_info_in_value', 'transaction_address_info', ['in_value'], unique=False)
    op.create_index('ix_transaction_address_info_in_count', 'transaction_address_info', ['in_count'], unique=False)
    op.drop_index(op.f('ix_transaction_address_info_vout_count'), table_name='transaction_address_info')
    op.drop_index(op.f('ix_transaction_address_info_vin_count'), table_name='transaction_address_info')
    op.drop_index(op.f('ix_transaction_address_info_spent_value'), table_name='transaction_address_info')
    op.drop_index(op.f('ix_transaction_address_info_received_value'), table_name='transaction_address_info')
    op.drop_column('transaction_address_info', 'vout_count')
    op.drop_column('transaction_address_info', 'vin_count')
    op.drop_column('transaction_address_info', 'spent_value')
    op.drop_column('transaction_address_info', 'received_value')
    ### end Alembic commands ###
