fix: grandfather pre-cutover stop episodes
This commit is contained in:
@@ -30,6 +30,22 @@ def upgrade() -> None:
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
# The policy starts at this deployment. Historical NULL values mean the
|
||||
# scanner never recorded reset observations, not that those old episodes
|
||||
# are still active. Mark both transitions complete so only stops created
|
||||
# after the migration can open a re-entry lock.
|
||||
op.execute(
|
||||
sa.text(
|
||||
"""
|
||||
UPDATE paper_trades
|
||||
SET reentry_gate_failed_at = closed_at,
|
||||
reentry_gate_requalified_at = closed_at
|
||||
WHERE status = 'closed'
|
||||
AND close_reason = 'stop'
|
||||
AND closed_at IS NOT NULL
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
||||
Reference in New Issue
Block a user