# Go-live Runbook — AARJAY GDP Portal

## Phase 1 — Prepare staging

1. Create a staging subdomain or folder.
2. Upload the latest ZIP contents.
3. Create a disposable staging database.
4. Import `install.sql` or run installer.
5. Login as seeded admin.
6. Change admin password.

## Phase 2 — Run automated checks

```bash
cd mvc
./scripts/static_preflight.sh
./scripts/php_lint_all.sh
DB_NAME=aarjay_gdp_regression MYSQL_USER=root ./scripts/test_install_sql.sh
BASE_URL=https://staging.example.com ./scripts/regression_smoke_test.sh
```

## Phase 3 — Browser checks

Open these pages as admin:

- `/system-health`
- `/gdp-gap-analysis`
- `/dashboard`
- `/recall`
- `/falsified-medicine`
- `/defective-stock`
- `/training-matrix`
- `/premises-equipment`
- `/accounts`
- `/advanced/reports`
- `/cold-chain-import`

## Phase 4 — Manual high-risk transaction tests

Create and then view/edit a test record for:

- Recall
- Falsified Medicine
- Defective Stock
- Training Matrix
- Technical Agreement
- Return
- Qualification
- MHRA Inspection
- Account Reopening
- Cold-chain Import

Record results in `STAGING_TEST_REPORT_TEMPLATE.md`.

## Phase 5 — Production deployment

1. Backup existing production files and database.
2. Upload latest verified build.
3. Run installer or import verified schema.
4. Confirm `install.lock` is present.
5. Confirm `.htaccess` protection.
6. Confirm upload directories are writable.
7. Confirm production `app.url` and DB config.
8. Change default admin password.
9. Re-run `/system-health`.

## Phase 6 — Post go-live

1. Create named users and permissions.
2. Disable/delete unused test accounts.
3. Enter real site/company profile data.
4. Load real suppliers/customers/products/batches if not migrated.
5. Confirm backups are scheduled.
6. Train admin/RP/QA users.

## Rollback

If go-live fails:

1. Restore previous file backup.
2. Restore previous DB backup.
3. Confirm login on prior version.
4. Capture error logs from failed deployment for correction.
