This commit is contained in:
Timothy Jaeryang Baek
2026-05-14 13:45:31 +09:00
parent 95840e307a
commit 6b1df94bf9
2 changed files with 16 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ Create Date: 2025-09-15 03:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
revision = 'a0b1c2d3e4f5'
@@ -15,7 +16,12 @@ depends_on = None
def upgrade():
op.create_index('ix_memory_user_id', 'memory', ['user_id'])
conn = op.get_bind()
inspector = sa.inspect(conn)
existing_indexes = {idx['name'] for idx in inspector.get_indexes('memory')}
if 'ix_memory_user_id' not in existing_indexes:
op.create_index('ix_memory_user_id', 'memory', ['user_id'])
def downgrade():

View File

@@ -19,16 +19,18 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
conn = op.get_bind()
inspector = sa.inspect(conn)
msg_cols = {c['name'] for c in inspector.get_columns('message')}
# Add 'reply_to_id' column to the 'message' table for replying to messages
op.add_column(
'message',
sa.Column('reply_to_id', sa.Text(), nullable=True),
)
pass
if 'reply_to_id' not in msg_cols:
op.add_column(
'message',
sa.Column('reply_to_id', sa.Text(), nullable=True),
)
def downgrade() -> None:
# Remove 'reply_to_id' column from the 'message' table
op.drop_column('message', 'reply_to_id')
pass