pyfedi/migrations/versions/fe1e3fbf5b9d_chat.py

56 lines
2 KiB
Python
Raw Normal View History

2024-02-17 20:05:57 +13:00
"""chat
Revision ID: fe1e3fbf5b9d
Revises: 75f5b458c2f9
Create Date: 2024-02-17 09:53:47.915062
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fe1e3fbf5b9d'
down_revision = '75f5b458c2f9'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('chat_message',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sender_id', sa.Integer(), nullable=True),
sa.Column('recipient_id', sa.Integer(), nullable=True),
sa.Column('body', sa.Text(), nullable=True),
sa.Column('body_html', sa.Text(), nullable=True),
sa.Column('reported', sa.Boolean(), nullable=True),
sa.Column('read', sa.Boolean(), nullable=True),
sa.Column('encrypted', sa.String(length=15), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['recipient_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['sender_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('chat_message', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_chat_message_recipient_id'), ['recipient_id'], unique=False)
batch_op.create_index(batch_op.f('ix_chat_message_sender_id'), ['sender_id'], unique=False)
with op.batch_alter_table('site', schema=None) as batch_op:
batch_op.add_column(sa.Column('auto_decline_referrers', sa.Text(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('site', schema=None) as batch_op:
batch_op.drop_column('auto_decline_referrers')
with op.batch_alter_table('chat_message', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_chat_message_sender_id'))
batch_op.drop_index(batch_op.f('ix_chat_message_recipient_id'))
op.drop_table('chat_message')
# ### end Alembic commands ###