"""add close_reason to paper_trades

Records how an open paper trade was closed (trailing | stop | target | manual) so
the close alert can summarise it and the UI can show why a position exited.

Revision ID: 013
Revises: 012
Create Date: 2026-06-30 00:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "013"
down_revision: Union[str, None] = "012"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column("paper_trades", sa.Column("close_reason", sa.String(length=10), nullable=True))


def downgrade() -> None:
    op.drop_column("paper_trades", "close_reason")
