# Deployment Notes

Manual content changes required after `drush cim`. These are content updates that cannot be transferred via configuration.

## Deployment Workflows

Because Drupal separates configuration (like Views and Content Types) from content (like the actual text on Exam pages), the deployment strategy varies depending on whether this is the initial launch or a standard update.

### 1. Initial Launch to Production
Since you likely have a lot of content and structure built locally, it is often easiest moving a database snapshot for the very first deployment so you don't have to recreate all content.

1. **Local:** Export the local database.
   ```bash
   ddev export-db --gzip --file=initial_launch.sql.gz
   ```
2. **Production:** Clone your Mercurial repository to production and install dependencies.
   ```bash
   composer install --no-dev --optimize-autoloader
   ```
3. **Production:** Import the `initial_launch.sql.gz` dump into your production database.
4. **Production:** Clear the cache.
   ```bash
   drush cr
   ```

### 2. Standard Deployment (Subsequent Updates)
Once the site is live, **DO NOT overwrite the production database** with a local dump, or you will lose real users and new content. Instead, flow *Code and Config* upward to production, while *Content* stays on production.

1. **Local:** Export configuration, commit code/config changes, and push.
   ```bash
   ddev drush cex   # Exports to config/compas/
   hg commit -m "Your deployment changes"
   hg push
   ```
2. **Production:** Pull the latest code and update dependencies.
   ```bash
   hg pull
   hg update
   composer install --no-dev --optimize-autoloader
   ```
3. **Production:** Run database updates (applies module schema updates).
   ```bash
   drush updb -y
   ```
4. **Production:** Import configuration (syncs settings from `config/compas/`).
   ```bash
   drush cim -y
   ```
5. **Production:** Clear the cache.
   ```bash
   drush cr
   ```
6. **Production:** Complete **Manual Steps**. Run any necessary content-generation PHP scripts (e.g., `drush scr scripts/...`) and complete any pending manual content updates listed below under **Pending Manual Steps**. Once completed, move them to the "Completed Steps" section.

---

## Pending Manual Steps

### Set Exam Type on landing pages
Each exam type landing page needs its `Exam Type` field set so the upcoming/past exam blocks appear.

| Page URL | Node title | Set `Exam Type` to |
|----------|------------|--------------------|
| /service/compas-py1 | การสอบ COMPAS-PY1 | COMPAS-PY1 |
| /service/compas-a1 | การสอบ COMPAS-A1 | COMPAS-A1 |

**How:** Edit each node → set the "Exam Type" field → Save.

### Set Subpage Type on existing landing pages
After enabling `compas_exam_pages` module, set `field_subpage_type` = `overview` on the existing exam type landing pages:

| Page URL | Node title | Set `Subpage Type` to |
|----------|------------|-----------------------|
| /service/compas-py1 | การสอบ COMPAS-PY1 | Overview |
| /service/compas-a1 | การสอบ COMPAS-A1 | Overview |

**How:** Edit each node → set the "Subpage Type" field to "ข้อมูลทั่วไป (Overview)" → Save.

### Create subpages for each exam type
Use the admin form at `/admin/config/compas/create-subpages` to create subpages for each exam type. Select the exam type and click "Create Missing Subpages". Then edit each created node to add real content.

### Clear old content from the Services page (Node 6)
Because the Services page layout is now driven entirely by a dynamic Views block, the old manual body text needs to be removed.
**How:** Edit the Services page (`/node/6` or `/บริการสอบ`) → remove all content from the "Body" field → Save.

### Merge the /service view with Node 6 alias
Run the deployment script to remove the standalone view page and associate the `/service` URL alias with Node 6.
**How:** Run the script using drush: `drush scr scripts/make_node6_service.php`

## Completed Steps

_(Move items here once done on production)_
