# Booking Restructure Rollout

## Scope
- Financial snapshot columns in `tour_booking`.
- New line-item table: `tour_booking_item`.
- New options table: `tour_booking_option` (includes configured options like `selected_hour`).
- Status improvements + history: `tour_booking_status_history`.
- Backfill from legacy tables `tour_booking_rates` and `tour_booking_extra`.

## Migrations Order
1. `m260211_000001_add_financial_columns_to_tour_booking`
2. `m260211_000002_create_tour_booking_item_table`
3. `m260211_000003_create_tour_booking_status_history_and_enhance_status`
4. `m260211_000004_backfill_tour_booking_item_from_legacy_tables`
5. `m260211_000005_create_tour_booking_option_table`
6. `m260211_000006_backfill_tour_booking_option_from_legacy_extras`

## Execute (Server)
```bash
php yii migrate/new --migrationPath=@app/migrations
php yii migrate/up --migrationPath=@app/migrations --interactive=0
```

## Verify
```sql
SELECT COUNT(*) FROM tour_booking_item;
SELECT COUNT(*) FROM tour_booking_option;
SELECT COUNT(*) FROM tour_booking_status_history;
```

## Deployment Strategy
1. Run migrations first.
2. Deploy API code (already dual-write compatible).
3. Validate new records in:
   - `tour_booking_item` for pax/activities/extras
   - `tour_booking_option` for `selected_hour`
4. Keep legacy tables active during transition.
5. Move reporting/admin reads to new tables after verification.

## Notes
- `BookingController::actionIndex` now writes to new tables only if they exist, so deployment is safe across phases.
- Legacy write path remains intact for compatibility.

