Fix newbook_current_rates column names + rollback on failed date

- schema defined gross_rate/net_rate but every query (fetch job,
  bookability, competitors) uses rate_gross/rate_net — rename the
  columns, with an idempotent DO-block migration for existing tables
- roll back the session when a date fails so one bad statement no
  longer poisons the whole sync run (every subsequent write was dying
  with 'current transaction is aborted')

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-05 14:07:01 +00:00
parent 4977768645
commit 33d466ed73
3 changed files with 16 additions and 3 deletions

View file

@ -342,6 +342,9 @@ async def run_fetch_current_rates(horizon_days: int = 720, start_date: date = No
except Exception as e:
logger.warning(f"Failed to fetch rates for {current_date}: {e}")
# A failed statement aborts the transaction — roll back so
# subsequent dates in this run can still be written
db.rollback()
# Step 5: Commit periodically
if day_count % COMMIT_BATCH_SIZE == 0: