---
name: "mysql-ghost-online-schema-change"
description: "Alter massive multi-million row MySQL tables in production without blocking writes."
metadata:
  author: "GitHub"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "alter large mysql table ghost"
  - "online schema change mysql"
  - "prevent lock on alter table"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# gh-ost MySQL Zero-Downtime Online Schema Changes

Applies schema migrations safely using GitHub gh-ost: asynchronous binary log inspection, ghost table streaming, row-copy throttling based on replica lag, and atomic metadata table swaps.

## When to Invoke
Invoke this skill whenever you need to:
- alter large mysql table ghost
- online schema change mysql
- prevent lock on alter table

## Execution SOP & Rules
1. Ensure binlog_format=ROW and binlog_row_image=FULL are enabled on the target MySQL instance.
2. Run gh-ost with --alter='ADD COLUMN status_code INT' --serve-socket-file for runtime inspection.
3. Configure --max-lag-millis=1000 and --throttle-control-replicas to protect downstream replication.
4. Complete the atomic table cutover automatically or with interactive cutover flag confirmation.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
