"""topic unread comment

Revision ID: 614be43d92f8
Revises: e12c528c38cb
Create Date: 2021-10-04 14:34:33.536652

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '614be43d92f8'
down_revision = 'e12c528c38cb'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_chat_topic_unread_comment',
    sa.Column('id', sa.String(length=64), nullable=False),
    sa.Column('chat_topic_id', sa.String(length=64), nullable=False),
    sa.Column('person_id', sa.String(length=64), nullable=False),
    sa.Column('comment_id', sa.String(length=64), nullable=False),
    sa.ForeignKeyConstraint(['chat_topic_id'], ['cmf_chat_topic.id'], ),
    sa.ForeignKeyConstraint(['comment_id'], ['cmf_comment.id'], ),
    sa.ForeignKeyConstraint(['person_id'], ['cmf_person.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_cmf_chat_topic_unread_comment_chat_topic_id'), 'cmf_chat_topic_unread_comment', ['chat_topic_id'], unique=False)
    op.create_index(op.f('ix_cmf_chat_topic_unread_comment_comment_id'), 'cmf_chat_topic_unread_comment', ['comment_id'], unique=False)
    op.create_index(op.f('ix_cmf_chat_topic_unread_comment_person_id'), 'cmf_chat_topic_unread_comment', ['person_id'], unique=False)
    op.drop_index('ix_cmf_topic_unread_comment_comment_id', table_name='cmf_topic_unread_comment')
    op.drop_index('ix_cmf_topic_unread_comment_person_id', table_name='cmf_topic_unread_comment')
    op.drop_index('ix_cmf_topic_unread_comment_topic_id', table_name='cmf_topic_unread_comment')
    op.drop_table('cmf_topic_unread_comment')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cmf_topic_unread_comment',
    sa.Column('id', sa.VARCHAR(length=64), autoincrement=False, nullable=False),
    sa.Column('topic_id', sa.VARCHAR(length=64), autoincrement=False, nullable=False),
    sa.Column('person_id', sa.VARCHAR(length=64), autoincrement=False, nullable=False),
    sa.Column('comment_id', sa.VARCHAR(length=64), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['comment_id'], ['cmf_comment.id'], name='cmf_topic_unread_comment_comment_id_fkey'),
    sa.ForeignKeyConstraint(['person_id'], ['cmf_person.id'], name='cmf_topic_unread_comment_person_id_fkey'),
    sa.ForeignKeyConstraint(['topic_id'], ['cmf_chat_topic.id'], name='cmf_topic_unread_comment_topic_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='cmf_topic_unread_comment_pkey')
    )
    op.create_index('ix_cmf_topic_unread_comment_topic_id', 'cmf_topic_unread_comment', ['topic_id'], unique=False)
    op.create_index('ix_cmf_topic_unread_comment_person_id', 'cmf_topic_unread_comment', ['person_id'], unique=False)
    op.create_index('ix_cmf_topic_unread_comment_comment_id', 'cmf_topic_unread_comment', ['comment_id'], unique=False)
    op.drop_index(op.f('ix_cmf_chat_topic_unread_comment_person_id'), table_name='cmf_chat_topic_unread_comment')
    op.drop_index(op.f('ix_cmf_chat_topic_unread_comment_comment_id'), table_name='cmf_chat_topic_unread_comment')
    op.drop_index(op.f('ix_cmf_chat_topic_unread_comment_chat_topic_id'), table_name='cmf_chat_topic_unread_comment')
    op.drop_table('cmf_chat_topic_unread_comment')
    # ### end Alembic commands ###
