68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
"""empty message
|
|
|
|
Revision ID: 51f049b860bb
|
|
Revises:
|
|
Create Date: 2026-07-13 22:23:49.155469
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '51f049b860bb'
|
|
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('conversations',
|
|
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('conversations', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_conversations_user_id'), ['user_id'], unique=False)
|
|
|
|
op.create_table('dialogs',
|
|
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('conversation_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('question', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('thought_nodes', sa.JSON(), nullable=False),
|
|
sa.Column('answer', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('dialogs', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_dialogs_conversation_id'), ['conversation_id'], unique=False)
|
|
|
|
op.create_table('runresults',
|
|
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')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('runresults')
|
|
with op.batch_alter_table('dialogs', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_dialogs_conversation_id'))
|
|
|
|
op.drop_table('dialogs')
|
|
with op.batch_alter_table('conversations', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_conversations_user_id'))
|
|
|
|
op.drop_table('conversations')
|
|
# ### end Alembic commands ###
|