合并代码,解决冲突
(cherry picked from commit 8b23bd771f04ceb1b9c1e3ae021d75001af5ba2f)
This commit is contained in:
1 parent
23badf7456
commit
93e99793d8
10 files changed
+626
-84
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""add chat_sessions table and session_id to chat_logs
|
||||
|
||||
Revision ID: c9d8e7f6a5b4
|
||||
Revises: e3f4a5b6c7d8
|
||||
Create Date: 2026-06-01 16:30:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c9d8e7f6a5b4'
|
||||
down_revision = 'e3f4a5b6c7d8'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'chat_sessions',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('session_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('agent_id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sa.String(length=255), nullable=False, server_default=''),
|
||||
sa.Column('status', sa.String(length=20), nullable=False, server_default='running'),
|
||||
sa.Column('external_conversation_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('last_active_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id']),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id']),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
op.create_index('ix_chat_sessions_session_id', 'chat_sessions', ['session_id'], unique=True)
|
||||
op.create_index('ix_chat_sessions_user_id', 'chat_sessions', ['user_id'], unique=False)
|
||||
op.create_index('ix_chat_sessions_agent_id', 'chat_sessions', ['agent_id'], unique=False)
|
||||
op.create_index('ix_chat_sessions_external_conversation_id', 'chat_sessions', ['external_conversation_id'], unique=False)
|
||||
op.create_index('ix_chat_sessions_created_at', 'chat_sessions', ['created_at'], unique=False)
|
||||
op.create_index('ix_chat_sessions_last_active_at', 'chat_sessions', ['last_active_at'], unique=False)
|
||||
op.create_index(
|
||||
'ix_chat_sessions_user_agent_last_active',
|
||||
'chat_sessions',
|
||||
['user_id', 'agent_id', 'last_active_at'],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
op.add_column('chat_logs', sa.Column('session_id', sa.String(length=100), nullable=True))
|
||||
op.create_index('ix_chat_logs_session_id', 'chat_logs', ['session_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('ix_chat_logs_session_id', table_name='chat_logs')
|
||||
op.drop_column('chat_logs', 'session_id')
|
||||
|
||||
op.drop_index('ix_chat_sessions_user_agent_last_active', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_last_active_at', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_created_at', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_external_conversation_id', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_agent_id', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_user_id', table_name='chat_sessions')
|
||||
op.drop_index('ix_chat_sessions_session_id', table_name='chat_sessions')
|
||||
op.drop_table('chat_sessions')
|
||||
Reference in new issue
Block a user