← Back to directory

Lint a PostgreSQL migration for lock and downtime risks: table rewrites, blockin...

https://code.halowerk.com/v1/pg-migration-safety

Overview

Lint a PostgreSQL migration for lock and downtime risks: table rewrites, blocking index builds, constraint scans, missing lock_timeout, transaction mistakes, with the lock mode of every statement.

Protocol x402 (POST)
Price $0.0040
Payment Asset USD Coin
Payment Network Base
Category crypto/transactions
Provider code
Source bazaar
Indexed 2026-11-20 14:09:44

Health

Status unknown
Latency (p50) —
Uptime (30d) —
Reliability Score —
Last Checked Never
Last Healthy Never
Consecutive Failures 0

x402 Payment Validation

Payment Requirements —
Asset Verified —
Facilitator —

Input Schema

{ "body": { "pg_version": 16, "sql": "ALTER TABLE users ADD COLUMN token uuid DEFAULT gen_random_uuid();\nCREATE INDEX users_email_idx ON users (email);" }, "bodyType": "json", "method": "POST", "type": "http" }

Output Schema

{ "example": { "limitations": [ "Static analysis of the SQL text; table sizes, existing indexes and constraints of the live database are not known.", "Volatility is looked up for built-in PostgreSQL 18 functions and uuid-ossp; other functions are reported as unknown." ], "result": { "findings": [ { "fix": "ALTER TABLE users ADD COLUMN IF NOT EXISTS token ...", "line": 1, "message": "ADD COLUMN token without IF NOT EXISTS outside a transaction fails when the migration is retried.", "rule": "prefer-robust-stmts", "severity": "info", "source": "https://squawkhq.com/docs/prefer-robust-stmts", "statement": 1 }, { "fix": "ALTER TABLE users ADD COLUMN token uuid; ALTER TABLE users ALTER COLUMN token SET DEFAULT gen_random_uuid(); -- then backfill in batches", "line": 1, "message": "DEFAULT uses the volatile function gen_random_uuid(); PostgreSQL rewrites users under an ACCESS EXCLUSIVE lock.", "rule": "adding-field-with-default", "severity": "error", "source": "https://squawkhq.com/docs/adding-field-with-default", "statement": 1 }, { "fix": "SET lock_timeout = '2s'; -- at the start of the migration, then retry on timeout", "line": 1, "message": "No lock_timeout is set before the first statement that locks an existing table; a long wait for the lock queues all other queries behind it.", "rule": "require-lock-timeout", "severity": "warning", "source": "https://squawkhq.com/docs/require-lock-timeout", "statement": 1 }, { "fix": "SET statement_timeout = '5min';", "line": 1, "message": "No statement_timeout is set before the first locking statement.", "rule": "require-statement-timeout", "severity": "info", "source": "https://squawkhq.com/docs/require-statement-timeout", "statement": 1 }, { "fix": "CREATE INDEX CONCURRENTLY users_email_idx ON users (...)", "line": 2, "message": "CREATE INDEX on users takes a SHARE lock and blocks writes while the index is built.", "rule": "require-concurrent-index-creation", "severity": "warning", "source": "https://squawkhq.com/docs/require-concurrent-index-creation", "statement": 2 }, { "fix": "CREATE INDEX CONCURRENTLY IF NOT EXISTS ...", "line": 2, "message": "CREATE INDEX without IF NOT EXISTS outside a transaction fails when the migration is retried.", "rule": "prefer-robust-stmts", "severity": "info", "source": "https://squawkhq.com/docs/prefer-robust-stmts", "statement": 2 } ], "settings": { "assume_in_transaction": false, "lock_timeout": null, "pg_version": 16, "statement_timeout": null }, "statements": [ { "blocks_reads": true, "blocks_writes": true, "kind": "alter_table", "line": 1, "lock_mode": "ACCESS EXCLUSIVE", "rules": [ "prefer-robust-stmts", "adding-field-with-default", "require-lock-timeout", "require-statement-timeout" ], "statement": 1, "tables": [ "users" ] }, { "blocks_reads": false, "blocks_writes": true, "kind": "create_index", "line": 2, "lock_mode": "SHARE", "rules": [ "require-concurrent-index-creation", "prefer-robust-stmts" ], "statement": 2, "tables": [ "users" ] } ], "summary": { "blocking_statements": 2, "errors": 1, "infos": 3, "new_tables": [], "statements": 2, "warnings": 2 } }, "service": "pg-migration-safety", "status": "success" }, "type": "json" }