"""last_chat_message для топиков

Revision ID: 9d5e46fbce25
Revises: 95cd50812249
Create Date: 2021-11-21 09:18:40.951635

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

# revision identifiers, used by Alembic.
revision = '9d5e46fbce25'
down_revision = '95cd50812249'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('cmf_chat_topic', sa.Column('last_chat_message_id', sa.String(length=64), nullable=True))
    op.create_index(op.f('ix_cmf_chat_topic_last_chat_message_id'), 'cmf_chat_topic', ['last_chat_message_id'], unique=False)
    op.create_foreign_key(None, 'cmf_chat_topic', 'cmf_chat_message', ['last_chat_message_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'cmf_chat_topic', type_='foreignkey')
    op.drop_index(op.f('ix_cmf_chat_topic_last_chat_message_id'), table_name='cmf_chat_topic')
    op.drop_column('cmf_chat_topic', 'last_chat_message_id')
    # ### end Alembic commands ###
