refac
This commit is contained in:
1 parent
5b1c42e81a
commit
2560533c1a
3 files changed
+78
-12
No files matched your search
@@ -0,0 +1,44 @@
|
||||
"""add memory type
|
||||
|
||||
Revision ID: 7b3f2a9c1d4e
|
||||
Revises: 4c5ce3d2f27f
|
||||
Create Date: 2026-06-25 00:00:00.000000
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = '7b3f2a9c1d4e'
|
||||
down_revision: Union[str, None] = '4c5ce3d2f27f'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
columns = {column['name'] for column in inspector.get_columns('memory')}
|
||||
indexes = {index['name'] for index in inspector.get_indexes('memory')}
|
||||
|
||||
if 'type' not in columns:
|
||||
op.add_column('memory', sa.Column('type', sa.String(), server_default='context', nullable=False))
|
||||
|
||||
if 'ix_memory_kind' not in indexes:
|
||||
op.create_index('ix_memory_kind', 'memory', ['type'])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
columns = {column['name'] for column in inspector.get_columns('memory')}
|
||||
indexes = {index['name'] for index in inspector.get_indexes('memory')}
|
||||
|
||||
if 'ix_memory_kind' in indexes:
|
||||
op.drop_index('ix_memory_kind', table_name='memory')
|
||||
|
||||
if 'type' in columns:
|
||||
op.drop_column('memory', 'type')
|
||||
Reference in new issue
Block a user