# GCMA Production Database Deploy Pack

For: **https://gcma.ait-academy.com**

## Files in this folder

| File | When to use |
|------|-------------|
| `02_production_upgrade_existing.sql` | **Recommended** — existing production DB with data (safe upgrade) |
| `gcma_production_schema.sql` | New/empty database only (structure, no data) |
| `gcma_production_master_seed.sql` | Optional master reference seed (REPLACE INTO) |
| `build_production_package.php` | Re-export schema/seed from local `gpcm_erp` |

## Option A — Existing production (keep data) ★

1. Backup production DB in cPanel / phpMyAdmin.
2. Open phpMyAdmin → select production database (often `aitacade_gcma_db`).
3. Import **`02_production_upgrade_existing.sql`**.
4. Deploy latest PHP/JS code from this project (overwrite app files).
5. Ensure production `.env` points to that database (see `.env.production.example`).
6. Hard refresh browser and test:
   - Master Data → Color (Add / Edit)
   - Role Permissions → Save
   - Item Code forms (Fabric, Pocketing, Thread, etc.)
   - Master Data → Warehouse

## Option B — Fresh empty database

1. Create empty DB + user in hosting panel.
2. Import `gcma_production_schema.sql`.
3. Import `gcma_production_master_seed.sql` (optional but recommended).
4. Run `php database/seed_admin.php` on server (or insert admin manually).
5. Deploy code + configure `.env`.

## Important

- Do **not** import full local transactional dumps into live production unless you intend to overwrite live data.
- After upgrade, Color codes skip soft-deleted collisions; next code continues from highest used number.
- Keep `APP_DEBUG=false` and a strong `JWT_SECRET` on production.
