Python/agent/alembic/versions/4269426de639_.py

99 lines
4.3 KiB
Python

"""empty message
Revision ID: 4269426de639
Revises:
Create Date: 2026-07-27 10:10:56.902466
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = '4269426de639'
down_revision: Union[str, Sequence[str], None] = None
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('captcharecord',
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('captcha', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('is_valid', sa.Boolean(), nullable=False),
sa.Column('is_verified', sa.Boolean(), nullable=False),
sa.Column('expired_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('email', 'captcha', 'expired_at')
)
with op.batch_alter_table('captcharecord', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_captcharecord_is_valid'), ['is_valid'], unique=False)
batch_op.create_index(batch_op.f('ix_captcharecord_is_verified'), ['is_verified'], unique=False)
op.create_table('conversationrecord',
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('user_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('is_deleted', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('conversationrecord', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_conversationrecord_is_deleted'), ['is_deleted'], unique=False)
batch_op.create_index(batch_op.f('ix_conversationrecord_user_id'), ['user_id'], unique=False)
op.create_table('dialogrecord',
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('conversation_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('user_prompt', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('thoughts', sa.JSON(), nullable=False),
sa.Column('result_output', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('dialogrecord', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_dialogrecord_conversation_id'), ['conversation_id'], unique=False)
op.create_table('resultrecord',
sa.Column('conversation_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('dialog_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('new_messages', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('conversation_id', 'dialog_id')
)
op.create_table('userrecord',
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('userrecord', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_userrecord_email'), ['email'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('userrecord', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_userrecord_email'))
op.drop_table('userrecord')
op.drop_table('resultrecord')
with op.batch_alter_table('dialogrecord', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_dialogrecord_conversation_id'))
op.drop_table('dialogrecord')
with op.batch_alter_table('conversationrecord', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_conversationrecord_user_id'))
batch_op.drop_index(batch_op.f('ix_conversationrecord_is_deleted'))
op.drop_table('conversationrecord')
with op.batch_alter_table('captcharecord', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_captcharecord_is_verified'))
batch_op.drop_index(batch_op.f('ix_captcharecord_is_valid'))
op.drop_table('captcharecord')
# ### end Alembic commands ###