ALTER TABLE in MySQL can lock the entire table. Use ALGORITHM=INPLACE or tools like gh-ost for safe migrations.
Why This Matters
A blocking ALTER TABLE on a large table causes application downtime. MySQL's online DDL and third-party tools like gh-ost allow non-blocking schema changes.
Adding a column: may require a table copy (locks writes)
Adding an index: can use INPLACE (no copy needed)
Changing column type: requires COPY (full lock)
Detection
Review migration files for ALTER TABLE statements without ALGORITHM hints:
squawk --pg-version=0 migration.sql # SQLFluff also workssqlfluff lint --dialect mysql migration.sql
Fix
-- MySQL 8.0+ online DDLALTER TABLE users ADD COLUMN bio TEXT, ALGORITHM=INPLACE, LOCK=NONE;-- For operations that can't be INPLACE, use gh-ost:-- gh-ost --alter "ADD COLUMN bio TEXT" \-- --database mydb --table users --execute