-- Update reviews table to work with new booking system
-- Add columns to track what type of booking this review is for
ALTER TABLE reviews ADD COLUMN IF NOT EXISTS main_booking_id BIGINT REFERENCES main_bookings(booking_id);
ALTER TABLE reviews ADD COLUMN IF NOT EXISTS review_type VARCHAR(20); -- 'beach', 'restaurant', 'market', 'adventure'

-- Update existing reviews to set the main_booking_id
-- This is a temporary solution until we migrate existing data properly
UPDATE reviews 
SET main_booking_id = booking_id 
WHERE booking_id IS NOT NULL AND main_booking_id IS NULL;

-- Set review_type based on what the review is for
UPDATE reviews 
SET review_type = 'beach' 
WHERE beach_place_id IS NOT NULL AND review_type IS NULL;

-- Remove the old booking_id column since we're using main_booking_id now
-- We'll do this in a separate script after data migration
-- ALTER TABLE reviews DROP COLUMN IF EXISTS booking_id;