refac
This commit is contained in:
1 parent
95840e307a
commit
6b1df94bf9
2 files changed
+16
-8
No files matched your search
@@ -6,6 +6,7 @@ Create Date: 2025-09-15 03:00:00.000000
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
revision = 'a0b1c2d3e4f5'
|
revision = 'a0b1c2d3e4f5'
|
||||||
@@ -15,7 +16,12 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
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():
|
def downgrade():
|
||||||
|
|||||||
+9
-7
@@ -19,16 +19,18 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade() -> 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
|
# Add 'reply_to_id' column to the 'message' table for replying to messages
|
||||||
op.add_column(
|
if 'reply_to_id' not in msg_cols:
|
||||||
'message',
|
op.add_column(
|
||||||
sa.Column('reply_to_id', sa.Text(), nullable=True),
|
'message',
|
||||||
)
|
sa.Column('reply_to_id', sa.Text(), nullable=True),
|
||||||
pass
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
# Remove 'reply_to_id' column from the 'message' table
|
# Remove 'reply_to_id' column from the 'message' table
|
||||||
op.drop_column('message', 'reply_to_id')
|
op.drop_column('message', 'reply_to_id')
|
||||||
|
|
||||||
pass
|
|
||||||
Reference in new issue
Block a user