"""BotTrade.released_at — user 'release from bot management' marker. Adds a single nullable timestamp column. When set: - recovery.py rehydration SKIPS this row (no watchdog re-register on restart) — the bot has stopped managing this position - reconciler / close paths don't touch it - the HL position itself is NOT closed; the user has taken back manual control of the open trade This is the escape hatch for "adopt → bot manages → user wants control back without closing". The bot stops driving but the HL position keeps running under the user's own decisions. Distinct from `closed_at`: a closed trade has a known exit_price/pnl and is finalised. A released trade has neither — it's still open on HL, just no longer in our watchdog. Backfill: every existing row gets released_at = NULL. No semantic change to any historical or already-open trade. Revision ID: 024 Revises: 023 Create Date: 2026-05-26 """ from alembic import op import sqlalchemy as sa revision = "024" down_revision = "023" branch_labels = None depends_on = None def upgrade() -> None: with op.batch_alter_table("bot_trades") as batch: batch.add_column(sa.Column( "released_at", sa.DateTime, nullable=True, )) def downgrade() -> None: with op.batch_alter_table("bot_trades") as batch: batch.drop_column("released_at")