"""empty message

Revision ID: 5b2ce9e13d39
Revises: 60159120a966
Create Date: 2016-01-21 12:51:33.245039

"""

# revision identifiers, used by Alembic.
revision = '5b2ce9e13d39'
down_revision = '60159120a966'

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

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(u'log_ibfk_2', 'log', type_='foreignkey')
    op.drop_constraint(u'transaction_item_ibfk_1', 'transaction_item', type_='foreignkey')
    op.drop_index('transaction_id', table_name='transaction_item')
    op.drop_column('log', 'card_transaction_id')
    op.drop_column('transaction_item', 'old_transaction_id')
    op.drop_table('old_transaction')
    op.drop_table('old_card_transaction')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('transaction_item', sa.Column('old_transaction_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_foreign_key(u'transaction_item_ibfk_1', 'transaction_item', 'old_transaction', ['old_transaction_id'], ['object_id'])
    op.create_index('transaction_id', 'transaction_item', ['old_transaction_id'], unique=False)
    op.add_column('log', sa.Column('card_transaction_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_foreign_key(u'log_ibfk_2', 'log', 'old_card_transaction', ['card_transaction_id'], ['object_id'])
    op.create_table('old_transaction',
    sa.Column('object_id', mysql.INTEGER(display_width=11), nullable=False),
    sa.Column('paid', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False),
    sa.Column('created', mysql.DATETIME(), nullable=False),
    sa.Column('user_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.Column('battels_term', mysql.VARCHAR(length=4), nullable=True),
    sa.Column('card_transaction_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['card_transaction_id'], [u'old_card_transaction.object_id'], name=u'old_transaction_ibfk_1'),
    sa.ForeignKeyConstraint(['user_id'], [u'user.object_id'], name=u'old_transaction_ibfk_2'),
    sa.PrimaryKeyConstraint('object_id'),
    mysql_default_charset=u'utf8',
    mysql_engine=u'InnoDB'
    )
    op.create_table('old_card_transaction',
    sa.Column('object_id', mysql.INTEGER(display_width=11), nullable=False),
    sa.Column('commenced', mysql.DATETIME(), nullable=False),
    sa.Column('completed', mysql.DATETIME(), nullable=True),
    sa.Column('access_code', mysql.VARCHAR(length=200), nullable=True),
    sa.Column('result_code', mysql.VARCHAR(length=2), nullable=True),
    sa.Column('eway_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('refunded', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.Column('user_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['user_id'], [u'user.object_id'], name=u'old_card_transaction_ibfk_1'),
    sa.PrimaryKeyConstraint('object_id'),
    mysql_default_charset=u'utf8',
    mysql_engine=u'InnoDB'
    )
    ### end Alembic commands ###
