How github/gh-ost works
Project type and purpose
• This is gh-ost, a Go-based command-line tool (an open-source utility) whose sole purpose is triggerless online schema migrations for MySQL.
• It reads the MySQL binary log, streams change events, applies them to a “ghost” table, and ultimately swaps tables, all without using triggers.
File structure
• Top-level directories
• go/cmd: entrypoint for the CLI (main.go)
• go/base: support code for context, logging, configuration
• go/binlog: parsing and reading MySQL binlog files/streams
• go/mysql: connection management and MySQL-specific utilities
• go/logic: the core migration engine (streamer, applier, migrator, throttler, hooks)
• go/sql: SQL statement builder, parser, encodings
• doc: end-user and developer documentation, images
• resources/hooks-sample: sample external hook scripts
• script: build, test, CI, bootstrap scripts
• Config/build/deployment
• go.mod / go.sum: Go modules
• Dockerfile.* and docker-compose.yml: containerized testing and packaging
• .github/workflows: CI, linting, replica-tests
README for additional insights
• Emphasis on:
• binlog-based incremental copy
• pause-and-resume (throttling)
• interactive control over a UNIX socket or TCP
• external hooks for custom behavior