# Existing Production cPanel Update Checklist

Use this checklist for a live server that is already installed.

This is not a reinstall checklist.

## Do Not Do These

- do not browse to `/install`
- do not delete `storage/app/installed.lock`
- do not wipe the production database
- do not replace the live `.env` with a development `.env`
- do not clear `storage/app/public` uploads

## Reality Check

On typical shared cPanel hosting, true zero-downtime deployment is rarely available.

Use this checklist to achieve a low-downtime rollout with the shortest practical maintenance window.

## Before the Maintenance Window

1. Build the update package locally:

```powershell
composer install --no-dev --optimize-autoloader
npm run build
powershell -ExecutionPolicy Bypass -File deploy\cpanel\build-update-package.ps1
```

2. Upload the update zip to the live cPanel app directory.
3. Extract it over the existing codebase without changing `.env` or uploaded files.
4. Confirm cPanel terminal access works.
5. Run preflight:

```bash
php artisan system:update-preflight
```

6. Review the output before starting the maintenance window.

## During the Maintenance Window

1. Open cPanel terminal in the application root.
2. Run:

```bash
chmod +x update-packages.sh
./update-packages.sh
```

3. Watch for:
   - migration failures
   - cache rebuild failures
   - queue restart warnings
   - postcheck failures

## Immediately After Update

Run these if you need to verify manually:

```bash
php artisan system:update-postcheck
php artisan migrate:status
php artisan queue:restart
```

## Browser Checks

Confirm:

- public homepage loads
- login works
- admin dashboard loads
- federation dashboard loads
- athlete dashboard loads
- safeguarding page loads
- videos page loads
- media files load from `/media/...`
- email test works

## Rollback Triggers

Rollback if any of these happen and cannot be fixed quickly:

- migration failure
- login failure
- repeated 500 or 419 errors on core routes
- broken admin dashboard
- broken file/media serving

## Rollback Inputs

The update flow keeps:

- `.env` backups in `storage/app/production-backups/env`
- database dumps in `storage/app/production-backups/database` when `mysqldump` is available

## Rollback Steps

1. restore previous code package
2. restore `.env` from backup if it changed unexpectedly
3. restore database backup if schema/data changes must be reversed
4. clear caches:

```bash
php artisan optimize:clear
```

5. bring the app online:

```bash
php artisan up
```
