"""chat conversations Revision ID: b4f7322082f4 Revises: fe1e3fbf5b9d Create Date: 2024-02-18 14:54:20.090872 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'b4f7322082f4' down_revision = 'fe1e3fbf5b9d' branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('conversation', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('reported', sa.Boolean(), nullable=True), sa.Column('read', sa.Boolean(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) with op.batch_alter_table('conversation', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_conversation_user_id'), ['user_id'], unique=False) op.create_table('conversation_member', sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('conversation_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['conversation_id'], ['conversation.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('user_id', 'conversation_id') ) with op.batch_alter_table('chat_message', schema=None) as batch_op: batch_op.add_column(sa.Column('conversation_id', sa.Integer(), nullable=True)) batch_op.create_index(batch_op.f('ix_chat_message_conversation_id'), ['conversation_id'], unique=False) batch_op.create_foreign_key(None, 'conversation', ['conversation_id'], ['id']) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('chat_message', schema=None) as batch_op: batch_op.drop_constraint(None, type_='foreignkey') batch_op.drop_index(batch_op.f('ix_chat_message_conversation_id')) batch_op.drop_column('conversation_id') op.drop_table('conversation_member') with op.batch_alter_table('conversation', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_conversation_user_id')) op.drop_table('conversation') # ### end Alembic commands ###