Quick revision
The short answer
I would move schema changes into the developers' normal workflow: migrations live with the code in Flyway or Liquibase, are reviewed, and are checked by a linter that flags risky operations. A pipeline then decides how each change runs, INSTANT or INPLACE for safe changes and gh-ost or pt-online-schema-change automatically for large tables, under guardrails such as replica lag throttling, short metadata lock timeouts, windows for the largest tables and automatic abort. Breaking changes follow expand and contract, every change is audited, and the DBA team owns the platform and handles exceptions instead of running every change by hand.
What to remember
In this answer, we designed a self-service schema change process. Migrations live with the code in Flyway or Liquibase and are checked by a linter built from past outages. The pipeline picks INSTANT or INPLACE for safe changes and gh-ost or pt-online-schema-change for large tables, under guardrails such as short metadata lock timeouts, lag and load throttling, windows for the largest tables and automatic abort. Breaking changes use expand and contract, every change is audited, and the DBA team owns the platform and the exceptions.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would move schema changes into the developers' normal workflow: migrations live with the code in Flyway or Liquibase, are reviewed, and are checked by a linter that flags risky operations. A pipeline then decides how each change runs, INSTANT or INPLACE for safe changes and gh-ost or pt-online-schema-change automatically for large tables, under guardrails such as replica lag throttling, short metadata lock timeouts, windows for the largest tables and automatic abort. Breaking changes follow expand and contract, every change is audited, and the DBA team owns the platform and handles exceptions instead of running every change by hand.
Why this question is asked
When a few DBAs run every schema change by hand across 120 databases, two things go wrong at once: developers wait days for simple changes, and the DBAs, working under pressure, occasionally run a blocking ALTER at the wrong time and cause an outage. Interviewers ask this design question to see whether we can turn expert knowledge into a safe, automated process without simply handing developers a loaded gun. In this answer, we will look at the flow from pull request to production, the linter, how the pipeline chooses the execution method, the guardrails, expand and contract for breaking changes, and the new role of the DBA team.
1The Shape of the Process
The core idea is that a schema change is code. A developer writes a migration file in the service's repository, it is reviewed with the code that needs it, and a pipeline applies it to each environment in order. What the DBAs know about safe changes is written into automated checks and into the pipeline's choice of method, so it applies to every change, not only to those a DBA happens to review.
- Migration file in the service repoFlyway or Liquibase
- Linter in CIflags risky operations
- Lint errors?YesFix, or request a DBA exceptionNoContinue
- Apply to staging copymeasure duration and method
- Pipeline picks the methodINSTANT, INPLACE or gh-ost
- Run with guardrailslag throttle, MDL timeout, abort
- Audit log and dashboardwho, what, when, how long
7 steps in order. Play them, or step through them one at a time.
Notice that people only appear at two points: the developer who writes and reviews the change, and the DBA who handles exceptions. Everything between is automated, and every step can stop the change.
2Migrations With the Code, Checked by a Linter
Each service keeps its migrations in Flyway or Liquibase, versioned with the code. That gives us ordering, history and the same change in every environment. The linter reads each new migration and checks it against the table it touches, using table sizes from a metadata service that collects information_schema statistics from all 120 databases nightly.
The rules come from past outages: column type changes on large tables, statements without explicit ALGORITHM and LOCK, adding NOT NULL columns without defaults, dropping columns still read by the current application version, renaming tables, and tables without primary keys. The linter explains each finding in plain language, so it teaches as it blocks.
3Letting the Pipeline Choose the Method
The developer states what should change; the pipeline decides how. For changes that MySQL can do as INSTANT, such as adding a column or renaming one, it runs the ALTER directly with ALGORITHM=INSTANT. For INPLACE changes on small tables, under about a million rows, it runs the ALTER with LOCK=NONE. For anything that needs a rebuild or copy on a large table, it runs gh-ost, or pt-online-schema-change where foreign keys rule out gh-ost, with standard settings. The thresholds live in configuration owned by the DBA team, so they can tune them without touching every service.
| Change and table size | Method | Typical duration |
|---|---|---|
| INSTANT-capable, any size | ALTER ... ALGORITHM=INSTANT | milliseconds |
| INPLACE, under 1M rows | ALTER ... LOCK=NONE | seconds |
| Rebuild or copy, large table | gh-ost with standard throttles | hours to days |
| Large table with foreign keys | pt-osc, DBA approval | hours to days |
| Top 20 largest tables | scheduled window, DBA on call | planned |
4Guardrails That Stop Bad Runs
Automation is only safe if it stops itself. Every DDL session sets lock_wait_timeout to a few seconds, so an ALTER that cannot get its metadata lock gives up and retries later instead of queueing all traffic behind it. gh-ost runs with limits on replica lag and on Threads_running, and a critical load limit that aborts the run. Before starting, the pipeline checks for long-running transactions on the target and for free disk space for a full copy. The largest tables only run in scheduled low-traffic windows with a DBA on call. And any run that exceeds its estimated duration by a large margin pauses and pages the owner.
5Expand and Contract for Breaking Changes
Some changes break the running application if applied in one step, such as renaming a column, splitting a table or changing a type that code depends on. During a deploy, old and new versions of the service run side by side, so the schema must work with both. Expand and contract solves this: first add the new structure (expand), deploy code that writes both and reads the new one, backfill, and only after the old version is gone remove the old structure (contract). The linter enforces part of this, for example by refusing to drop a column that the previous release still reads, based on a simple annotation or a usage check.
6Audit, Dashboards and the DBA Team's New Role
Every change is recorded: which service, which migration, which database, the method chosen, start and end times, and the outcome. A dashboard shows running and recent changes, so anyone investigating an incident can see at once whether a schema change was involved. Over time, the same data shows which rules prevent problems and which only slow people down.
The DBA team's job changes from running changes to owning the platform: the linter rules, the method thresholds, the gh-ost configuration, the guide for developers, and the exceptions, such as foreign key tables or the largest tables. They review only what the rules flag, which is a small share of all changes, and their knowledge now protects every change instead of the ones they personally run.
7Follow-up questions
How do we roll this out without disrupting teams?
Start with the linter in warning mode on all repositories, so teams see findings without being blocked, while the pipeline handles a few volunteer services end to end. Once the false positives are fixed, make errors blocking and move services over in groups.
What if a migration fails halfway on MySQL?
MySQL commits each DDL statement, so a multi-statement migration can leave partial changes. That is why the linter allows one DDL change per migration file, and the pipeline marks the failed run, alerts the owner, and requires a fix-forward migration rather than editing history.
How do we keep 120 databases consistent?
The pipeline compares the applied migration history and the actual schema of each database with what the repository expects, and reports drift, such as a hand-made index, so it can be added to the code or removed.
8Conclusion
In this answer, we designed a self-service schema change process. Migrations live with the code in Flyway or Liquibase and are checked by a linter built from past outages. The pipeline picks INSTANT or INPLACE for safe changes and gh-ost or pt-online-schema-change for large tables, under guardrails such as short metadata lock timeouts, lag and load throttling, windows for the largest tables and automatic abort. Breaking changes use expand and contract, every change is audited, and the DBA team owns the platform and the exceptions.
Open with
I would make schema changes part of the normal code workflow and put the DBAs' knowledge into automation. Migrations live in each service's repository, in Flyway or Liquibase, and are reviewed with the code.
Then, if they want more
A linter checks each migration against the real size of the table and flags risky operations: type changes on large tables, missing ALGORITHM and LOCK clauses, NOT NULL columns without defaults, and drops of columns the current release still reads.
The developer says what to change and the pipeline decides how: INSTANT where MySQL supports it, INPLACE with LOCK=NONE for small tables, and gh-ost automatically for rebuilds of large tables, or pt-online-schema-change when foreign keys rule out gh-ost.
Guardrails stop bad runs: lock_wait_timeout of a few seconds so an ALTER never queues traffic behind a metadata lock, throttling on replica lag and load, a critical load abort, checks for long transactions and disk space, and scheduled windows for the largest tables. Breaking changes follow expand and contract, so old and new application versions both work during a deploy.
Every change goes to an audit log and a dashboard. And the DBA team changes role: they own the linter rules, the thresholds and the tooling, and handle exceptions, instead of running every change by hand.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Schema changes across 120 MySQL databases are run by hand by a few DBAs and cause...": https://scrivio-interview-library.netlify.app/databases/mysql/06650f0277/