"""group_id_and_updated_at_for_topic_group

Revision ID: 9cc084b1c4eb
Revises: d110e9b808da
Create Date: 2018-03-05 18:39:53.306386

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9cc084b1c4eb'
down_revision = 'd110e9b808da'
branch_labels = None
depends_on = None
set_updated_at = """
UPDATE topic_groups SET updated_at = created_at
"""
set_deleted = """
UPDATE topic_groups SET deleted = False
"""


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('topic_groups', sa.Column('deleted', sa.Boolean(), nullable=True))
    op.add_column('topic_groups', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.create_index(op.f('ix_topic_groups_deleted'), 'topic_groups', ['deleted'], unique=False)
    # ### end Alembic commands ###
    op.execute(set_updated_at)
    op.execute(set_deleted)


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_topic_groups_deleted'), table_name='topic_groups')
    op.drop_column('topic_groups', 'updated_at')
    op.drop_column('topic_groups', 'deleted')
    # ### end Alembic commands ###
