> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rocky.global/llms.txt
> Use this file to discover all available pages before exploring further.

# DEPLOY CURACAO CITIES

# Guide to Adding Curaçao Cities in Production

This guide explains how to safely add all Curaçao cities in the production environment.

## ✅ Safety Features

The `cities:add-curacao` command is designed to be **100% safe in production**:

* ✅ **Does not delete data**: Only adds cities, never deletes or modifies existing data
* ✅ **Idempotent**: Can be run multiple times without issues
* ✅ **Transactional**: Uses database transactions (if an error occurs, everything is rolled back)
* ✅ **Checks for duplicates**: Verifies whether cities already exist before adding them
* ✅ **Dry-run mode**: Lets you preview what would be added without making real changes

## 📋 Prerequisites

1. Make sure the country Curaçao exists in the `countries` table
   * ISO2 code: `CW`
   * If it doesn't exist, run the seeder first: `php artisan db:seed --class=CountriesSeeder`

2. Back up the database (recommended but not critical, since we are only adding data):
   ```bash theme={null}
   # Example with MySQL
   mysqldump -u usuario -p nombre_bd > backup_antes_curacao_$(date +%Y%m%d_%H%M%S).sql
   ```

## 🚀 Deployment Process

### Step 1: Dry-Run Mode (Recommended)

First, run the command in dry-run mode to see which cities would be added:

```bash theme={null}
php artisan cities:add-curacao --dry-run
```

This will show:

* Which country was found
* How many cities already exist
* Which cities would be added
* **It will NOT make any changes to the database**

### Step 2: Run in Production

If the dry-run looks good, run the command without the `--dry-run` flag:

```bash theme={null}
php artisan cities:add-curacao
```

The command will:

1. Look up the country Curaçao (CW)
2. Check which cities already exist
3. Show the cities that will be added
4. Ask for confirmation before proceeding
5. Add only the cities that do not exist
6. Show a summary of what was added

### Step 3: Verification

Verify that the cities were added correctly:

```bash theme={null}
# View all Curaçao cities in the database
php artisan tinker
>>> App\Models\Cities::where('country_code', 'CW')->pluck('name')
```

Or verify at checkout:

1. Go to any checkout form
2. Select the country "Curaçao"
3. Verify that the cities appear (Willemstad, Bandariba, etc.)

## 📊 Cities That Are Added

The command adds the following 24 main Curaçao cities:

1. Willemstad (Capital)
2. Bandariba
3. Bandabou
4. Sint Michiel
5. St. Michiel
6. Santa Rosa
7. Sint Michiel Liber
8. Brievengat
9. Barber
10. Dorp Soto
11. Otrabanda
12. Sabana Westpunt
13. Westpunt
14. Lagun
15. Tera Kora
16. Nieuwpoort
17. Playa Kanoa
18. Playa Kalki
19. Boca San Pedro
20. Rincon
21. Dorp Sint Willebrordus
22. Groot Sint Joris
23. Sint Joris
24. Klein Sint Joris

## 🔄 Running Multiple Times

The command is completely safe to run multiple times. If a city already exists, it will simply be skipped and the command will continue with the rest.

## ⚠️ Troubleshooting

### Error: "Curaçao (CW) not found in countries table"

**Solution**: Run the countries seeder first:

```bash theme={null}
php artisan db:seed --class=CountriesSeeder
```

### Database permission error

**Solution**: Verify that the database user has INSERT permissions on the `cities` table.

### Cities do not appear at checkout

**Solution**:

1. Verify that the `/api/get-states?country=CW` endpoint returns the cities
2. Clear the cache if necessary: `php artisan cache:clear`
3. Verify that the JavaScript code is loading the cities correctly

## 📝 Additional Notes

* The CSV `cities_202505192231.csv` has already been updated with these cities
* If you run the full cities seeder (`CitiesSeeder`), these cities will also be included
* The command uses transactions, so if an error occurs, all changes are automatically rolled back

## 🔗 Related Files

* Command: `app/Console/Commands/AddWillemstadCity.php`
* CSV: `cities_202505192231.csv`
* Model: `app/Models/Cities.php`
* API Endpoint: `routes/web.php` (line 44: `/api/get-states`)
