# Upgrade Guide

## Upgrading from v1.x to v2.0

### Step 1: Backup

```bash
# Backup database
php artisan db:backup

# Backup files
cp -r .env .env.backup
cp -r storage storage.backup
```

### Step 2: Update Files

Replace all application files with the new version, preserving:
- `.env` (environment configuration)
- `storage/` directory
- Any custom files in `public/`

### Step 3: Update Dependencies

```bash
composer install --no-dev --optimize-autoloader
npm install
npm run build
```

### Step 4: Run Migrations

```bash
php artisan migrate --force
```

### Step 5: Clear Cache

```bash
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

### Step 6: Update Cron

Ensure your crontab has the updated command:

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

## Database Changes in v2.0

- `activities` table: Removed (migrated to `activity_logs`)
- `ai_automations` table: Removed (merged into `automation_rules`)
- New performance indexes on `leads`, `deals`, `tasks`, `invoices`, `whatsapp_messages`, `activity_logs`
- New `envato_purchase_code` setting in `settings` table
