mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 08:08:48 +02:00
59 lines
2.7 KiB
Python
59 lines
2.7 KiB
Python
"""add chat run audit logs
|
|
|
|
Revision ID: ecb99a158fbf
|
|
Revises: 794baf50635b
|
|
Create Date: 2026-07-14 22:22:06.035643
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'ecb99a158fbf'
|
|
down_revision: Union[str, Sequence[str], None] = '794baf50635b'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('chatrunlog',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('request_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('requested_thread_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
|
sa.Column('response_thread_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
|
sa.Column('model', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('user_prompt', sa.Text(), nullable=True),
|
|
sa.Column('tool_calls', sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), 'postgresql'), server_default='[]', nullable=False),
|
|
sa.Column('assistant_response', sa.Text(), nullable=True),
|
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('error', sa.Text(), nullable=True),
|
|
sa.Column('started_at', sa.DateTime(), nullable=False),
|
|
sa.Column('completed_at', sa.DateTime(), nullable=True),
|
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_chatrunlog_expires_at'), 'chatrunlog', ['expires_at'], unique=False)
|
|
op.create_index(op.f('ix_chatrunlog_request_id'), 'chatrunlog', ['request_id'], unique=True)
|
|
op.create_index(op.f('ix_chatrunlog_requested_thread_id'), 'chatrunlog', ['requested_thread_id'], unique=False)
|
|
op.create_index(op.f('ix_chatrunlog_response_thread_id'), 'chatrunlog', ['response_thread_id'], unique=False)
|
|
op.create_index(op.f('ix_chatrunlog_status'), 'chatrunlog', ['status'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_chatrunlog_status'), table_name='chatrunlog')
|
|
op.drop_index(op.f('ix_chatrunlog_response_thread_id'), table_name='chatrunlog')
|
|
op.drop_index(op.f('ix_chatrunlog_requested_thread_id'), table_name='chatrunlog')
|
|
op.drop_index(op.f('ix_chatrunlog_request_id'), table_name='chatrunlog')
|
|
op.drop_index(op.f('ix_chatrunlog_expires_at'), table_name='chatrunlog')
|
|
op.drop_table('chatrunlog')
|
|
# ### end Alembic commands ###
|