Static SQL Migration Linter & Lock-Risk Analyzer
Zero-Downtime Schema Evolution β Day 1
Detect ACCESS EXCLUSIVE table locks, missing lock_timeout guards, non-concurrent index builds, and destructive DDL before a migration PR ever reaches staging.
A single unguarded ALTER TABLE or non-concurrent CREATE INDEX can acquire an ACCESS EXCLUSIVE or SHARE lock and stall every application query behind a lock queue pile-up. Today you will build and test a deterministic SQL migration linter that catches lock-risk anti-patterns statically in CI.
Expand-Contract & Lock-Risk Migration Simulator
SET lock_timeout = '2s';
ALTER TABLE users ADD COLUMN display_name TEXT;
CREATE INDEX CONCURRENTLY idx_users_display_name ON users (display_name);The official reference codebase for Day 1 is hosted in the repository. Clone the repository and navigate to tests/day1-migration-linter.spec.ts to run the working solution.
git clone https://github.com/777abhi/db-migration-qe-roadmap.git
cd db-migration-qe-roadmap/tests/day1-migration-linter.spec.tsRun & Inspect the SQL Migration Linter
Clone the standalone reference repository and run the Day 1 Vitest suite.
git clone https://github.com/777abhi/db-migration-qe-roadmap.git
cd db-migration-qe-roadmap
npm ci
npm run test:day1if (/^CREATE\s+(UNIQUE\s+)?INDEX\b/.test(upper) && !/\bCONCURRENTLY\b/.test(upper)) {
recordLock('SHARE');
findings.push({
ruleId: 'INDEX_NOT_CONCURRENT',
severity: 'HIGH',
lockLevel: 'SHARE',
message: 'CREATE INDEX without CONCURRENTLY acquires a SHARE lock, blocking all writes.',
remediation: 'Use CREATE INDEX CONCURRENTLY (outside a transaction block).',
});
}- Classified PostgreSQL/SQL lock levels (NONE, SHARE_UPDATE_EXCLUSIVE, SHARE, ACCESS_EXCLUSIVE).
- Enforced SET lock_timeout guards to prevent lock-queue pile-ups.
- Blocked unsafe NOT NULL additions, DROP COLUMN, ALTER TYPE, and unvalidated foreign keys.
π§ Knowledge Check
Why is CREATE INDEX without CONCURRENTLY dangerous on a high-traffic production table?