# Gallery Migration Instructions

## Problem: MySQL Connection Error

The gallery tables need 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 Gallery Migration
Once MySQL is running, run:

```bash
php run_gallery_migration.php
```

### 3. 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_gallery_table.sql`

## What the Migration Creates:

### Gallery Table:
- `id` - Primary key
- `user_id` - User who uploaded (Foreign Key)
- `pet_id` - Pet in photo (Foreign Key)
- `photo_path` - Path to uploaded photo
- `caption` - Photo caption
- `type` - Post type (general, appointment_experience, etc.)
- `created_at` - Upload timestamp
- `updated_at` - Last update timestamp

### Gallery Likes Table:
- `id` - Primary key
- `gallery_id` - Photo being liked (Foreign Key)
- `user_id` - User who liked (Foreign Key)
- `created_at` - Like timestamp
- Unique constraint - One like per user per photo

## Features After Migration:

### PawGram Social Gallery:
- **Photo Upload** - Share pet moments
- **Like System** - Heart likes with real-time count
- **Caption Templates** - Quick text templates
- **Post Types** - General, Experience, Milestone, etc.
- **Trending Section** - Weekly popular posts
- **User Profiles** - Consistent user avatars

### Integration:
- **Complete Appointment** - Auto-share to gallery
- **Pet Profiles** - Connect to pet information
- **Social Engagement** - Like and interact with posts

## Test After Migration:

1. **Gallery Feed**: `http://localhost/PawsGram/?page=gallery`
2. **Upload Photo**: `http://localhost/PawsGram/?page=gallery&action=upload`
3. **Complete Appointment**: Test auto-share feature

## 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
4. Run SQL manually via phpMyAdmin

## Complete Platform Features:

After migration, you'll have:
- **Schedule Management** - Calendar with location support
- **Complete Appointment** - Photo + notes + social share
- **PawGram Gallery** - Instagram-style social feed
- **Experience Tracking** - Rich appointment experiences
- **Social Integration** - Community engagement features

The PawGram platform will be fully functional after gallery migration!
