# Database Migration Instructions

## Problem: MySQL Connection Error

The appointment experiences table needs to be created, but MySQL is not running.

## Solution Steps:

### 1. Start MySQL Server
```bash
# Start XAMPP MySQL
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start

# Or start via XAMPP Control Panel
# Open XAMPP Control Panel and click "Start" for MySQL
```

### 2. Run Migration Script
Once MySQL is running, run one of these scripts:

#### Option A: Simple Migration (Recommended)
```bash
php create_table_simple.php
```

#### Option B: Full Migration
```bash
php run_experiences_migration.php
```

### 3. Verify Table Creation
After running migration, you should see:
- Green success message
- Table structure display
- Link to test the feature

### 4. Test Complete Appointment Feature
Visit: `http://localhost/PawsGram/?page=schedules`

Click the complete button on any scheduled appointment to test the new feature.

## What the Migration Creates:

The `appointment_experiences` table with these fields:
- `id` - Primary key
- `schedule_id` - Links to appointments
- `user_id` - User who completed
- `pet_id` - Pet involved
- `experience_notes` - User's experience notes
- `photo_path` - Uploaded photo path
- `shared_to_pawgram` - Whether shared to social feed
- `created_at` - Timestamp
- `updated_at` - Last update timestamp

## Troubleshooting:

### If MySQL still doesn't start:
1. Check port 3306 is not in use
2. Restart XAMPP completely
3. Check XAMPP logs for errors
4. Try starting MySQL manually from terminal

### If migration fails:
1. Verify database name: `pawjoy_db`
2. Verify MySQL user: `root` (no password)
3. Check database permissions

## Alternative: Manual SQL Execution

If scripts don't work, you can run SQL manually:

1. Open phpMyAdmin (http://localhost/phpmyadmin)
2. Select `pawjoy_db` database
3. Go to "SQL" tab
4. Paste and run the SQL from `create_experiences_table.sql`

## Feature Overview

Once the table is created, you'll have:
- Photo upload for appointment experiences
- Experience notes and templates
- Optional sharing to PawGram social feed
- Experience history tracking
- Draft saving functionality

The complete appointment feature will be fully functional after migration!
