"""add message status and recallable_until

Revision ID: 009_add_message_status
Revises:
Create Date: 2026-06-14

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '009_add_message_status'
down_revision: Union[str, None] = '008_add_agent_password'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Add status field
    op.add_column(
        'messages',
        sa.Column('status', sa.String(20), nullable=False, server_default='sent')
    )
    # Add recallable_until field
    op.add_column(
        'messages',
        sa.Column('recallable_until', sa.DateTime(timezone=True), nullable=True)
    )


def downgrade() -> None:
    op.drop_column('messages', 'recallable_until')
    op.drop_column('messages', 'status')