"""messages new indexes

Revision ID: b73e67b82c56
Revises: 1830be56c2a8
Create Date: 2017-09-26 23:44:50.337797

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b73e67b82c56'
down_revision = '1830be56c2a8'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('messages',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=128), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('receiver_id', sa.Integer(), nullable=True),
    sa.Column('author_deleted', sa.Boolean(), nullable=True),
    sa.Column('receiver_deleted', sa.Boolean(), nullable=True),
    sa.Column('unread', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['receiver_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_messages_author_deleted'), 'messages', ['author_deleted'], unique=False)
    op.create_index(op.f('ix_messages_author_id'), 'messages', ['author_id'], unique=False)
    op.create_index(op.f('ix_messages_created_at'), 'messages', ['created_at'], unique=False)
    op.create_index(op.f('ix_messages_receiver_deleted'), 'messages', ['receiver_deleted'], unique=False)
    op.create_index(op.f('ix_messages_receiver_id'), 'messages', ['receiver_id'], unique=False)
    op.create_index(op.f('ix_messages_unread'), 'messages', ['unread'], unique=False)
    op.create_index(op.f('ix_comments_topic_id'), 'comments', ['topic_id'], unique=False)
    op.create_index(op.f('ix_polls_answers_topic_id'), 'polls_answers', ['topic_id'], unique=False)
    op.create_index(op.f('ix_polls_votes_poll_answer_id'), 'polls_votes', ['poll_answer_id'], unique=False)
    op.create_index(op.f('ix_polls_votes_topic_id'), 'polls_votes', ['topic_id'], unique=False)
    op.create_index(op.f('ix_topic_groups_group_id'), 'topic_groups', ['group_id'], unique=False)
    op.create_index(op.f('ix_topics_group_id'), 'topics', ['group_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_topics_group_id'), table_name='topics')
    op.drop_index(op.f('ix_topic_groups_group_id'), table_name='topic_groups')
    op.drop_index(op.f('ix_polls_votes_topic_id'), table_name='polls_votes')
    op.drop_index(op.f('ix_polls_votes_poll_answer_id'), table_name='polls_votes')
    op.drop_index(op.f('ix_polls_answers_topic_id'), table_name='polls_answers')
    op.drop_index(op.f('ix_comments_topic_id'), table_name='comments')
    op.drop_index(op.f('ix_messages_unread'), table_name='messages')
    op.drop_index(op.f('ix_messages_receiver_id'), table_name='messages')
    op.drop_index(op.f('ix_messages_receiver_deleted'), table_name='messages')
    op.drop_index(op.f('ix_messages_created_at'), table_name='messages')
    op.drop_index(op.f('ix_messages_author_id'), table_name='messages')
    op.drop_index(op.f('ix_messages_author_deleted'), table_name='messages')
    op.drop_table('messages')
    # ### end Alembic commands ###
