VICE//DEV
BACK TO ALL MISSIONSSTACK: TypeScript · pgsql-ast-parser · React 19 · node:sqlite · SARIF
MigrationPilot SQL safety analysis UI showing risk score meters, detected DDL violations, and zero-downtime replacement SQL
CASE STUDY BRIEF // MISSION 04✓ VERIFIED · 14/14 PASS

MIGRATIONPILOT — ARCHITECTURE & EVIDENCE BRIEF

OFFLINE STATIC DDL ANALYSIS PIPELINE

  1. 1. SQL INPUTFile / Folder / API
  2. 2. AST PARSEpgsql-ast-parser
  3. 3. 25 RULESLock / Rewrite / FK
  4. 4. SCORE + FIXSafe SQL Rewrite
  5. 5. SARIF + DBnode:sqlite Store

01 // PROBLEM

Routine DDL migrations (`SET NOT NULL`, non-concurrent indexes, unvalidated foreign keys) silently acquire `ACCESS EXCLUSIVE` locks and cause production outages.

02 // SOLUTION

Created an offline-first TypeScript monorepo (`packages/analyzer`, `packages/cli`, `apps/web`) implementing 25 deterministic PostgreSQL safety rules and generating copyable zero-downtime alternatives (e.g., `NOT VALID` + `VALIDATE CONSTRAINT`).

03 // TECHNICAL ARCHITECTURE

Uses `pgsql-ast-parser` with lexical/regex fallback across PostgreSQL 12–17 DDL statements, scored across Availability, Data Loss, Lock Contention, and Compatibility, persisted locally via Node's native `node:sqlite`, and exported as SARIF v2.1.0.

04 // INDIVIDUAL CONTRIBUTIONS

Independently developed with AI coding-agent assistance; Daniel designed rule severity model, CLI exit codes, SARIF mapping, and zero-downtime remediation templates.

05 // DESIGN DECISIONS

Built 100% deterministic offline static analysis requiring no LLM API keys or live database connection, keeping CI execution predictable and air-gap safe.

06 // SECURITY CONSIDERATIONS & CAVEATS

Zero external network calls during analysis. Scope note: sample PR workflow runs the analyzer with `|| true` for non-blocking SARIF upload unless `--fail-on high` gating is enabled.

07 // TEST EVIDENCE

Executed `pnpm test` (14 Vitest tests passing in `packages/analyzer/tests/analyzer.test.ts`), `pnpm build`, and `pnpm --filter @migrationpilot/web build`.

08 // CHALLENGES & TRADE-OFFS

Static AST inspection catches structural lock hazards instantly without live catalog row counts, so large-table amplification relies on configured metadata hints.

09 // REPOSITORY: https://github.com/0xyz-exe/migrationpilot · APACHE 2.0