# Phase 3 Strategic Decisions - Finalized
**Date:** 2025-10-12
**Status:** ✅ Decisions Made - Ready for Implementation

---

## Decision Points - FINALIZED

### ✅ Decision 1: Venue Naming

**Question:** What should Event 1's venue be called?

**DECISION:** **Grosvenor House Ballroom**

**Details:**
- Location: Mayfair, London
- One of London's most prestigious event venues
- Famous ballroom with 2,000+ capacity
- Real venue that will be reused for multiple events

**Implementation:**
```sql
INSERT INTO venues (name, slug, address, city, country, venue_type)
VALUES (
    'Grosvenor House Ballroom',
    'grosvenor-house-ballroom',
    '86-90 Park Lane',
    'London',
    'United Kingdom',
    'ballroom'
);
```

**Rationale:**
- Prestigious, real-world venue
- Clear, professional naming
- Reusable across multiple events
- Matches target market (high-end events)

---

### ✅ Decision 2: Legacy Events (123, 124)

**Question:** Keep or delete empty test events?
- Event 123: "Test Concert 2025" - 0 seats
- Event 124: "24234234" - 0 seats

**DECISION:** **Clear/Ignore for now**

**Implementation:**
- Don't migrate Event 123/124 to new venue architecture
- Keep in database but mark as legacy
- Can delete later after Phase 3 is stable
- Focus ONLY on Event 1 migration

**Rationale:**
- Clean slate for new architecture
- Event 123/124 have no real data (0 seats)
- Not worth migration effort
- Can be safely ignored

---

### ✅ Decision 3: Backward Compatibility Timeline

**Question:** How long support dual architecture?

**DECISION:** **3 months (Recommended)**

**Timeline:**
```
Week 1-2: Phase 3 Implementation
Week 3-4: Testing & Staging Deployment
Week 5-8: Production rollout (10% → 50% → 100%)
Week 9-12: Monitoring & Bug Fixes
Month 4+: Deprecate old architecture
```

**Dual Support Period (3 months):**
- **Months 1-2:** Both old and new architecture active
  - Event 1 uses new venue architecture
  - Old events (123, 124, 999999) use old architecture
  - VenueController supports both paths
  - No breaking changes to production

- **Month 3:** Gradual deprecation
  - Warning logs for old architecture usage
  - Migration of remaining events (if any)
  - Frontend updates deployed

- **Month 4+:** Old architecture removed
  - Drop `event_id` from `venue_templates`
  - Remove backward compatibility code
  - Clean up unused fields

**Implementation Strategy:**
```php
// VenueController - Dual support
public function getVenue($id) {
    $venue = Venue::find($id);

    // NEW: Real venue
    if ($venue) {
        return $this->formatVenueResponse($venue);
    }

    // OLD: Fallback to event-as-venue (backward compatibility)
    $event = Event::find($id);
    if ($event) {
        return $this->formatLegacyVenueResponse($event);
    }

    return response()->json(['error' => 'Not found'], 404);
}
```

**Feature Flags:**
```php
// config/features.php
return [
    'venue_architecture_v2' => env('FEATURE_VENUE_V2', false),
    'enforce_venue_selection' => env('FEATURE_ENFORCE_VENUE', false),
];
```

**Rationale:**
- **3 months is safest** - gives time to discover edge cases
- Allows gradual rollout (10% → 50% → 100%)
- Gives team time to migrate any new events created
- Reduces risk of production incidents
- Easier to rollback if issues found

---

## Migration Scope - FINALIZED

### ✅ Event 1 → Venue 1 (Grosvenor House Ballroom)

**Source Event:**
- Event ID: 1
- Event Name: "Test Event"
- Seats: 1,155 (1,048 individual + 97 tables)
- Sections: 6
- Reservations: 78 (71 booked + 7 expired holds)
- Orders: 164
- Current Status: Active production data

**Target Venue:**
- Venue ID: 1 (new)
- Venue Name: **"Grosvenor House Ballroom"**
- Slug: `grosvenor-house-ballroom`
- Location: 86-90 Park Lane, London, UK
- Type: ballroom
- Capacity: 1,155 (from Event 1 template)

**Venue Template:**
- Template ID: (existing from Event 1)
- Name: "Grosvenor House Standard Layout"
- Type: standard
- Seats: 1,048
- Tables: 97
- Sections: 6
- Version: 1
- Status: published

**Event-Venue Link:**
```sql
-- event_venues table
event_id: 1
venue_id: 1
venue_template_id: (Event 1's template ID)
is_primary: true
```

---

## Events NOT Migrated

### Event 123: "Test Concert 2025"
- Seats: 0
- Status: Empty test event
- Action: **Ignore** (leave in old architecture)
- Can delete after Phase 3 stable

### Event 124: "24234234"
- Seats: 0
- Status: Empty test event
- Action: **Ignore** (leave in old architecture)
- Can delete after Phase 3 stable

### Event 999999: (QR Validation)
- Status: Legacy test event
- Action: **Keep** (do not migrate, do not delete)
- Used for QR validation testing

---

## Implementation Checklist

### Pre-Implementation (NOW)

- [x] Decision 1: Venue name → "Grosvenor House Ballroom" ✅
- [x] Decision 2: Event 123/124 → Ignore/Clear ✅
- [x] Decision 3: Backward compatibility → 3 months ✅
- [ ] Create database backup
- [ ] Review phase-3-strategic-analysis.md
- [ ] Update venue-separation-architecture.md with venue name

### Week 1: Backend Schema & Migration

**Task 3.2: Schema & Models (6 hours)**
- [ ] Create `venues` table migration
- [ ] Create `event_venues` join table migration
- [ ] Add `venue_id` to `venue_templates` (nullable)
- [ ] Create Venue model
- [ ] Create EventVenue model
- [ ] Update Event and VenueTemplate models
- [ ] Write unit tests

**Task 3.3: Event 1 Migration Script (4 hours)**
- [ ] Create artisan command: `migrate:event-to-venue`
- [ ] Implement Event 1 → Grosvenor House migration
- [ ] Add rollback capability
- [ ] Add verification queries
- [ ] Test on staging

**Task 3.4: Data Migration (2 hours)**
- [ ] Run migration on Event 1
- [ ] Verify 1,155 seats intact
- [ ] Verify 78 reservations intact
- [ ] Verify 164 orders intact
- [ ] Verify venue template linked

### Week 1: Backend API Refactor

**Task 3.10: VenueController Refactor (8 hours)**
- [ ] Refactor `getVenues()` to return venues table
- [ ] Add dual support (new venues + legacy events)
- [ ] Refactor `getVenue($id)` with fallback
- [ ] Implement `POST /api/venues` (create venue)
- [ ] Implement `GET /api/venues/{id}/templates`
- [ ] Add feature flags
- [ ] Update AdminController::createEvent() for venue_id
- [ ] Write integration tests

### Week 2: Frontend Updates

**Task 3.11: Event Wizard Update (6 hours)**
- [ ] Create VenueSelector component
- [ ] Replace LocationStep with VenueStep
- [ ] Update form schema (remove address, add venue_id)
- [ ] Fetch venues from GET /api/venues
- [ ] Display Grosvenor House as option
- [ ] Add "Create New Venue" button
- [ ] Update API integration
- [ ] Test event creation flow

### Week 2: Testing & Deployment

**Task 3.7: Testing (6 hours)**
- [ ] Unit tests: Venue, EventVenue models
- [ ] Integration tests: VenueController
- [ ] E2E test: Event 1 booking still works
- [ ] E2E test: Create new event with Grosvenor House
- [ ] E2E test: Venue selector displays correctly
- [ ] Performance benchmarks (< 200ms queries)

**Task 3.8: Deployment (4 hours)**
- [ ] Update API documentation
- [ ] Create migration runbook
- [ ] Deploy to staging
- [ ] Smoke tests on staging
- [ ] Gradual production rollout (10% → 50% → 100%)
- [ ] Monitor for 48 hours

---

## Success Criteria

### Data Integrity
- ✅ Event 1 has exactly 1,155 seats (unchanged)
- ✅ Event 1 has exactly 78 reservations (unchanged)
- ✅ Event 1 has exactly 164 orders (unchanged)
- ✅ Grosvenor House Ballroom created as Venue 1
- ✅ Event 1 linked to Venue 1 via event_venues
- ✅ Venue template transferred to Venue 1

### Functionality
- ✅ Event 1 booking flow works (E2E test passes)
- ✅ New events can select Grosvenor House Ballroom
- ✅ VenueController returns real venues (not events)
- ✅ Event wizard includes venue selector
- ✅ Backward compatibility maintained (3 months)

### Performance
- ✅ Venue queries < 200ms
- ✅ Event listing < 300ms
- ✅ No N+1 queries

---

## Rollback Plan

### Level 1: Application Rollback (Instant)
```bash
git checkout previous-tag
php artisan config:clear
# No data changes, just code
```

### Level 2: Data Rollback (5 minutes)
```sql
-- Undo Event 1 venue link
DELETE FROM event_venues WHERE event_id = 1;
UPDATE venue_templates SET venue_id = NULL WHERE event_id = 1;
DELETE FROM venues WHERE slug = 'grosvenor-house-ballroom';
```

### Level 3: Full Rollback (15 minutes)
```bash
./scripts/restore-db.sh backup_20251012_HHMMSS.sql
```

---

## Timeline

**Total Duration:** 40 hours (2 weeks)

**Week 1:** Backend (Schema, Migration, APIs)
- Days 1-2: Tasks 3.2 (Schema)
- Day 3: Task 3.3 (Migration Script)
- Days 4-5: Task 3.10 (VenueController Refactor)

**Week 2:** Frontend + Testing
- Days 1-2: Task 3.11 (Frontend Venue Selector)
- Day 3: Task 3.7 (Testing)
- Day 4: Task 3.8 (Deployment)
- Day 5: Buffer/Documentation

**Month 1-3:** Dual support active
**Month 4+:** Deprecate old architecture

---

## Risk Mitigation

### Critical Risks Addressed

**1. Event 1 Data Loss**
- ✅ Backup before migration
- ✅ Transaction wrapping
- ✅ Automated verification
- ✅ Three-level rollback

**2. Production Disruption**
- ✅ 3-month dual support
- ✅ Feature flags
- ✅ Gradual rollout
- ✅ Monitoring

**3. Frontend Breaking Changes**
- ✅ VenueController backward compatibility
- ✅ Old events still work
- ✅ Phased frontend deployment

---

## Next Step: Create Backup & Start Task 3.2

```bash
# 1. Create backup (30 seconds)
cd /Users/charlie/code/showprima
./scripts/backup-db.sh

# 2. Verify backup
php -r "
require 'vendor/autoload.php';
\$app = require_once 'bootstrap/app.php';
\$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
echo 'Event 1 Seats: ' . DB::table('seats')->where('event_id', 1)->count() . \"\n\";
echo 'Event 1 Reservations: ' . DB::table('seat_reservations')->where('event_id', 1)->count() . \"\n\";
echo 'Event 1 Orders: ' . DB::table('orders')->where('event_id', 1)->count() . \"\n\";
"
# Expected: 1155 seats, 78 reservations, 164 orders

# 3. Start Task 3.2: Schema & Models
```

---

**Document Status:** ✅ FINALIZED - Ready for Implementation
**Approvals:** User decisions received
**Blocking Issues:** None
**Next Task:** 3.2 Schema & Models (6 hours)
