Files
docupulse/migrations/versions/e7e4ff171f7a_add_message_attachments_table_and_.py
2025-05-26 15:11:26 +02:00

53 lines
2.1 KiB
Python

"""add message attachments table and update message model
Revision ID: e7e4ff171f7a
Revises: 0f48943140fa
Create Date: 2025-05-26 15:00:18.557702
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e7e4ff171f7a'
down_revision = '0f48943140fa'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('message_attachment',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('message_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('path', sa.String(length=512), nullable=False),
sa.Column('type', sa.String(length=100), nullable=True),
sa.Column('size', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('message', schema=None) as batch_op:
batch_op.drop_column('attachment_path')
batch_op.drop_column('attachment_type')
batch_op.drop_column('has_attachment')
batch_op.drop_column('attachment_size')
batch_op.drop_column('attachment_name')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('message', schema=None) as batch_op:
batch_op.add_column(sa.Column('attachment_name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('attachment_size', sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('has_attachment', sa.BOOLEAN(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('attachment_type', sa.VARCHAR(length=100), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('attachment_path', sa.VARCHAR(length=512), autoincrement=False, nullable=True))
op.drop_table('message_attachment')
# ### end Alembic commands ###