# Release and Rollback Checklist

## Pre-Release
- Run PHP syntax checks on critical files:
  - `doctor.php`
  - `doctor_api.php`
  - `index.php`
  - `api/clinic_results.php`
  - `modules/clinic_api.php`
  - `modules/doctor/results.php`
  - `modules/doctor/dashboard.php`
  - `modules/dashboard.php`
  - `modules/billing.php`
  - `modules/reports.php`
  - `modules/inventory.php`
- Verify migrations are already applied in target environment (runtime DDL is disabled), including `php migrations/run_038_enterprise_pack.php` (قوالب الطبيب، طلبات التموين، QC يومي، جلسات، webhook، جسر التكامل).
- Verify API clients can send `X-API-Key` header (query key still works temporarily with warning).
- Smoke test these flows:
  - Doctor login and dashboard
  - Doctor alerts and inbox
  - Doctor notes save/edit
  - Doctor appointments add with overlap handling
  - Lab dashboard operations panel
  - Billing aging cards and debt reminder action
  - Inventory forecast column and warning counters
  - Clinic API docs page and API test tool

## Post-Release Monitoring (first 24h)
- Monitor PHP error log for:
  - `schema missing` warnings
  - API authentication/rate-limit spikes
  - unexpected CSRF failures
- Monitor key business KPIs:
  - Critical cases reviewed latency
  - Backlog orders
  - Daily TAT trend
  - Aging 90+ bucket trend
  - Inventory items forecasted to run out in <=14 days

## Rollback Plan
1. Switch traffic to previous stable build.
2. Clear opcode/application cache.
3. Re-run smoke tests on previous build.
4. Keep database schema as-is (no destructive rollback required by this release).
5. If API clients fail after rollback, allow both header and query key auth at gateway level until clients are aligned.
6. Re-open release after root-cause analysis and targeted fix.

## Notes
- This release intentionally avoids runtime migrations.
- If schema warnings appear, run pending SQL migrations before re-enabling new features.
