feat(chat): 单向聊天可二次激活 单向聊天可二次激活,未删除方聊天消息保留,双向删除后记录清空
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""merage chat_participant and read_status
|
||||
|
||||
Revision ID: 43b2d2efe0f7
|
||||
Revises: e9466c397aa2
|
||||
Create Date: 2025-05-16 22:20:04.592819
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '43b2d2efe0f7'
|
||||
down_revision: Union[str, None] = 'e9466c397aa2'
|
||||
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.drop_index('idx_read_status_on_chat_id', table_name='system_read_status')
|
||||
op.drop_index('idx_read_status_on_user_id', table_name='system_read_status')
|
||||
op.drop_table('system_read_status')
|
||||
op.add_column('system_chat_participant', sa.Column('last_read_message_id', sa.Integer(), nullable=True))
|
||||
op.add_column('system_chat_participant', sa.Column('last_del_message_id', sa.Integer(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('system_chat_participant', 'last_del_message_id')
|
||||
op.drop_column('system_chat_participant', 'last_read_message_id')
|
||||
op.create_table('system_read_status',
|
||||
sa.Column('last_read_message_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
|
||||
sa.Column('user_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('chat_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
|
||||
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False, comment='自增id'),
|
||||
sa.Column('created_at', mysql.DATETIME(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='创建时间'),
|
||||
sa.Column('updated_at', mysql.DATETIME(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='更新时间'),
|
||||
sa.ForeignKeyConstraint(['chat_id'], ['system_chats.id'], name='system_read_status_ibfk_1'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['system_users.user_id'], name='system_read_status_ibfk_2'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
comment='聊天消息读取状态表',
|
||||
mysql_comment='聊天消息读取状态表',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_index('idx_read_status_on_user_id', 'system_read_status', ['user_id'], unique=False)
|
||||
op.create_index('idx_read_status_on_chat_id', 'system_read_status', ['chat_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user