"""add msg_id column to attachments Revision ID: 5dfa093e7b2b Revises: 1dc4564189c1 Create Date: 2024-04-08 23:08:51.542184 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = '5dfa093e7b2b' down_revision: Union[str, None] = '1dc4564189c1' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.add_column('attachments', sa.Column('msg_id', sa.BigInteger(), nullable=True)) op.execute("UPDATE attachments SET msg_id = (message->>'id')::bigint") op.alter_column('attachments', 'msg_id', nullable=False) op.create_index(op.f('ix_attachments_msg_id'), 'attachments', ['msg_id'], unique=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_attachments_msg_id'), table_name='attachments') op.drop_column('attachments', 'msg_id') # ### end Alembic commands ###