Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>pgfenceNew to Visual Studio Code? Get it now.
pgfence

pgfence

flvmnt

| (0) | Free
Postgres migration safety: real-time lock mode analysis, risk scoring, and safe rewrite suggestions
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

pgfence for VS Code

Postgres migration safety: real-time lock mode analysis, risk scoring, and safe rewrite suggestions directly in your editor.

Features

Diagnostics - Inline warnings and errors for dangerous migration patterns:

  • Lock mode escalation (ACCESS EXCLUSIVE, SHARE, etc.)
  • Risk levels (SAFE, LOW, MEDIUM, HIGH, CRITICAL)
  • Policy violations (missing lock_timeout, CONCURRENTLY inside transaction, etc.)

Safe Rewrite Quick Fixes - One-click fixes that replace dangerous patterns with safe expand/contract sequences. No other tool provides this.

Hover Information - Hover over any flagged statement to see:

  • Exact lock mode acquired
  • What operations are blocked (reads, writes, DDL)
  • Risk level and safe alternatives

Status Bar - At-a-glance error/warning count for the current workspace.

Requirements

pgfence must be installed in your project or globally:

# In your project (recommended)
npm install -D @flvmnt/pgfence

# Or globally
npm install -g @flvmnt/pgfence

The extension automatically discovers the LSP server from:

  1. Workspace node_modules/@flvmnt/pgfence
  2. Global npm installation

Configuration

Setting Default Description
pgfence.minPostgresVersion 14 Minimum PostgreSQL version to assume (affects which operations are instant)
pgfence.requireLockTimeout true Require SET lock_timeout in every migration
pgfence.requireStatementTimeout true Require SET statement_timeout in every migration
pgfence.statsFilePath "" Path to pgfence-stats.json for size-aware risk scoring
pgfence.trace.server "off" Trace LSP server communication (for debugging)

Commands

  • pgfence: Show Output - Open the pgfence output channel
  • pgfence: Restart Server - Restart the LSP server

What pgfence detects

pgfence analyzes 37 migration patterns including:

  • ADD COLUMN ... NOT NULL without DEFAULT (ACCESS EXCLUSIVE)
  • CREATE INDEX without CONCURRENTLY (SHARE lock, blocks writes)
  • ALTER COLUMN TYPE (full table rewrite)
  • ADD CONSTRAINT ... FOREIGN KEY without NOT VALID
  • DROP TABLE, TRUNCATE (CRITICAL risk)
  • Missing lock_timeout / statement_timeout policies
  • CREATE INDEX CONCURRENTLY inside a transaction (will fail)
  • And 30+ more patterns

Like pgfence?

If pgfence helps keep your migrations safe, give it a star on GitHub. It helps others discover the project.

Links

  • Documentation
  • CLI & GitHub Action
  • Report Issues

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft