# Database Setup Fix

## Issue
The database `travel_system` has partial tables without proper foreign keys. You need to start fresh with the complete SQL dump.

## Solution: Use the SQL Dump (Recommended)

The `database/uae_travel_system.sql` file contains the complete database structure with all tables, foreign keys, and seeded data.

### Option 1: Command Line (Fast)

```bash
# Drop the existing database and recreate
mysql -u root -p
```

```sql
DROP DATABASE IF EXISTS travel_system;
CREATE DATABASE uae_travel_system CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
exit;
```

```bash
# Import the complete SQL dump
mysql -u root -p uae_travel_system < database/uae_travel_system.sql
```

### Option 2: phpMyAdmin (Easy)

1. Open http://localhost/phpmyadmin
2. Select the `travel_system` database
3. Click "Operations" tab
4. Scroll down and click "Drop the database (DROP)"
5. Confirm deletion
6. Click "New" to create a new database
7. Name: `uae_travel_system`
8. Collation: `utf8mb4_unicode_ci`
9. Click "Create"
10. Select the new `uae_travel_system` database
11. Click "Import" tab
12. Choose file: `database/uae_travel_system.sql`
13. Click "Go"

### Update .env File

After importing, update your `.env` file:

```env
DB_DATABASE=uae_travel_system
```

(Change from `travel_system` to `uae_travel_system`)

### Verify Installation

```bash
# Check migrations are marked as ran
php artisan migrate:status

# Start the server
php artisan serve
```

## Why Use the SQL Dump?

The SQL dump includes:
- ✅ All 22 tables properly created
- ✅ All foreign key constraints correctly set
- ✅ All indexes and relationships
- ✅ Complete seeded data (7 Emirates, 35 hotels, 40 activities, etc.)
- ✅ Already tested and verified structure

Running migrations requires the correct order and can have dependency issues. The SQL dump is a single, tested, working snapshot of the complete database.

## What's in the SQL Dump?

| Table | Rows | Description |
|-------|------|-------------|
| users | 0 | User authentication |
| countries | 1 | United Arab Emirates |
| regions | 7 | All 7 Emirates |
| cities | 7 | Main cities |
| areas | 7 | Tourist areas |
| hotels | 35 | Hotels across 3★/4★/5★ tiers |
| activities | 40 | Categorized activities |
| restaurants | 23 | Dining options |
| marinas | 3 | Marina locations |
| yachts | 10 | Yacht rental options |
| transports | 171 | Transport options (within + intercity) |
| flight_routes | 27 | International flight routes |
| trip_plans | 0 | Trip planning data |
| itinerary* | 0 | Itinerary tables |
| cost_calculations | 0 | Cost calculation records |
| leads | 0 | Quote submissions |
| cache | 0 | Application cache |
| sessions | 0 | User sessions |
| jobs | 0 | Queue jobs |
| migrations | 22 | Migration tracking |

## After Import

Your database will be ready with:
- All tables created
- All foreign keys working
- All data seeded
- Ready to use immediately

Then just run:

```bash
php artisan serve
```

And visit: http://localhost:8000

🎉 Done!
