Files
OpenHands/openhands/app_server/app_lifespan/alembic/versions/005.py
chuckbutkus d5e66b4f3a SAAS: Introducing orgs (phase 1) (#11265)
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: rohitvinodmalhotra@gmail.com <rohitvinodmalhotra@gmail.com>
Co-authored-by: Hiep Le <69354317+hieptl@users.noreply.github.com>
Co-authored-by: Tim O'Farrell <tofarr@gmail.com>
2026-01-15 22:03:31 -05:00

47 lines
1.3 KiB
Python

"""Update conversation_metadata table to match StoredConversationMetadata dataclass
Revision ID: 005
Revises: 004
Create Date: 2025-11-11 00:00:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = '005'
down_revision: Union[str, Sequence[str], None] = '004'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
with op.batch_alter_table('conversation_metadata') as batch_op:
# Drop columns not in StoredConversationMetadata dataclass
batch_op.drop_column('github_user_id')
# Alter user_id to become nullable
batch_op.alter_column(
'user_id',
existing_type=sa.String(),
nullable=True,
)
def downgrade() -> None:
"""Downgrade schema."""
with op.batch_alter_table('conversation_metadata') as batch_op:
# Add back removed column
batch_op.add_column(sa.Column('github_user_id', sa.String(), nullable=True))
# Restore NOT NULL constraint
batch_op.alter_column(
'user_id',
existing_type=sa.String(),
nullable=False,
)