"""revise message, remove *_create tables

Revision ID: cac85b1ccf05
Revises: 369cb62f5bce
Create Date: 2017-11-12 20:47:03.505143

"""

# revision identifiers, used by Alembic.
revision = 'cac85b1ccf05'
down_revision = '369cb62f5bce'
branch_labels = None
depends_on = None

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

def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('grainbin_info_message')
    op.drop_table('device_info_message')
    op.drop_column('message', 'received')
    op.drop_column('message', 'to_send')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('message', sa.Column('to_send', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
    op.add_column('message', sa.Column('received', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
    op.create_table('device_info_message',
    sa.Column('id', mysql.VARCHAR(length=20), nullable=False),
    sa.Column('hardware_version', mysql.VARCHAR(length=7), nullable=True),
    sa.Column('software_version', mysql.VARCHAR(length=7), nullable=True),
    sa.Column('received', mysql.DATETIME(), nullable=True),
    sa.Column('database_service', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
    sa.Column('device_service', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
    sa.Column('grainbin_service', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
    sa.Column('grainbin_count', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset=u'latin1',
    mysql_engine=u'InnoDB'
    )
    op.create_table('grainbin_info_message',
    sa.Column('id', mysql.VARCHAR(length=20), nullable=False),
    sa.Column('bus_number', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.Column('cables', sa.BLOB(), nullable=True),
    sa.Column('received', mysql.DATETIME(), nullable=True),
    sa.Column('device_id', mysql.VARCHAR(length=20), nullable=False),
    sa.ForeignKeyConstraint(['device_id'], [u'device_info_message.id'], name=u'grainbin_info_message_ibfk_1', ondelete=u'CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset=u'latin1',
    mysql_engine=u'InnoDB'
    )
    # ### end Alembic commands ###
