MP065CRITICALFree

ban-lock-table

What It Detects

Explicit LOCK TABLE in migrations blocks queries and can cause deadlocks.

Why It's Dangerous

LOCK TABLE acquires an explicit lock that can block reads and writes. PostgreSQL DDL statements automatically acquire the correct lock — explicit LOCK TABLE is rarely needed and often indicates a flawed migration strategy. High lock modes (EXCLUSIVE, ACCESS EXCLUSIVE) block all other operations.

Bad Example

LOCK TABLE users IN ACCESS EXCLUSIVE MODE;

Good Example

-- Let PostgreSQL acquire locks automatically via DDL
-- No explicit LOCK TABLE needed
ALTER TABLE users ADD COLUMN email TEXT;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP065: false

Or change its severity:

# .migrationpilotrc.yml
rules:
  MP065:
    severity: warning