# 🚀 Updater System - Quick Reference Card

## 📍 Access Points

| What | URL |
|------|-----|
| Main Dashboard | `/admin/updater` |
| Upload Update | `/admin/updater/create` |
| System Status | `/admin/updater/status` |

---

## 🔧 Commands

```bash
# Create update package
php artisan updater:create-package {version} [options]

# With files
php artisan updater:create-package 1.2.0 --include-files

# With migrations  
php artisan updater:create-package 1.2.0 --include-migrations

# Complete package
php artisan updater:create-package 1.2.0 --title="Update" --include-files --include-migrations
```

---

## 📦 Update Package Structure

```
update_v1.2.0.zip
├── update.json        # REQUIRED
├── files/            # Optional
├── migrations/       # Optional  
└── scripts/         # Optional
```

### Minimal update.json:
```json
{
    "version": "1.2.0",
    "title": "Bug Fixes"
}
```

---

## 🎯 Common Tasks

### Create Backup:
1. Go to `/admin/updater`
2. Click "Create Backup"
3. Done!

### Install Update:
1. Upload ZIP file
2. Review details
3. Click "Install"
4. Wait for completion

### Rollback Update:
1. Find update in list
2. Click "Rollback"
3. Confirm

---

## 🛠️ Troubleshooting

### Backup fails:
```bash
mkdir -p storage/app/backups
chmod -R 755 storage/app/backups
```

### Upload fails:
```ini
# php.ini
upload_max_filesize = 500M
post_max_size = 500M
```

### Permission errors:
```bash
chmod -R 755 storage/
chmod -R 755 bootstrap/cache/
```

---

## 📂 Important Paths

| What | Path |
|------|------|
| Backups | `storage/app/backups/` |
| Updates | `storage/app/updates/` |
| Temp | `storage/app/temp/` |
| Logs | `storage/logs/laravel.log` |

---

## 🔐 Security

- ✅ Admin only access
- ✅ ZIP validation
- ✅ Auto backup
- ✅ Version check
- ✅ Error logging

---

## ⚡ Quick Setup

```bash
# 1. Migrate
php artisan migrate

# 2. Set version
echo "APP_VERSION=1.0.0" >> .env

# 3. Create dirs
mkdir -p storage/app/{backups,updates,temp}
chmod -R 755 storage/app

# 4. Clear cache
php artisan config:clear
```

---

## 📊 Status Values

| Status | Meaning |
|--------|---------|
| pending | Ready to install |
| installing | Currently installing |
| completed | Successfully installed |
| failed | Installation failed |
| rolled_back | Reverted to backup |

---

## ⚙️ Configuration

File: `Modules/Updater/config/config.php`

```php
'max_file_size' => 500 * 1024 * 1024,  // 500MB
'backup' => [
    'auto_create_before_update' => true,
    'max_backup_files' => 10,
],
```

---

## 🎯 Best Practices

1. ✅ Always backup before update
2. ✅ Test on staging first  
3. ✅ Monitor logs after
4. ✅ Keep backups 30+ days
5. ✅ Use maintenance mode

---

## 📞 Support Commands

```bash
# View logs
tail -f storage/logs/laravel.log

# Clear caches
php artisan cache:clear
php artisan config:clear
php artisan view:clear

# Check permissions
ls -la storage/

# Test backup
php artisan tinker
>>> app(Modules\Updater\Services\UpdaterService::class)->createBackup('test');
```

---

## ✅ Pre-flight Checklist

Before update:
- [ ] Backup created
- [ ] Staging tested
- [ ] Changelog reviewed
- [ ] Maintenance mode on
- [ ] Team notified

After update:
- [ ] Status is "completed"
- [ ] Version updated
- [ ] Features tested
- [ ] Logs checked
- [ ] Maintenance mode off

---

**Remember**: Always backup! 🔐

