diff --git a/backend/schema.sql b/backend/schema.sql index 724bde6..6515534 100644 --- a/backend/schema.sql +++ b/backend/schema.sql @@ -115,7 +115,7 @@ CREATE TABLE IF NOT EXISTS booking_com_rates ( availability_status VARCHAR(30), -- available | sold_out | no_data rate_gross DECIMAL(10,2), currency VARCHAR(10) DEFAULT 'GBP', - room_type VARCHAR(100), + room_type TEXT, breakfast_included BOOLEAN DEFAULT FALSE, free_cancellation BOOLEAN DEFAULT FALSE, no_prepayment BOOLEAN DEFAULT FALSE, @@ -124,6 +124,9 @@ CREATE TABLE IF NOT EXISTS booking_com_rates ( scraped_at TIMESTAMPTZ DEFAULT NOW() ); +-- Widen room_type on tables created before the VARCHAR(100) → TEXT change +ALTER TABLE booking_com_rates ALTER COLUMN room_type TYPE TEXT; + CREATE INDEX IF NOT EXISTS idx_booking_com_rates_hotel_date ON booking_com_rates(hotel_id, rate_date); CREATE INDEX IF NOT EXISTS idx_booking_com_rates_date ON booking_com_rates(rate_date); CREATE INDEX IF NOT EXISTS idx_booking_com_rates_scraped ON booking_com_rates(scraped_at DESC); diff --git a/backend/services/booking_scraper.py b/backend/services/booking_scraper.py index a3bd9ce..b1217b9 100644 --- a/backend/services/booking_scraper.py +++ b/backend/services/booking_scraper.py @@ -349,6 +349,9 @@ async def scrape_date( rates_saved += 1 except Exception as e: logger.warning(f"Error saving hotel/rate: {e}") + # A failed statement aborts the transaction — roll back so the + # remaining hotels in this batch can still be saved + db.rollback() continue db.commit()