Installation

pgfence requires Node.js 20+. Install globally or use via npx.

Global Install

bash
npm install -g @flvmnt/pgfence
bash
pnpm add -g @flvmnt/pgfence

npx (no install)

bash
npx @flvmnt/pgfence analyze migrations/*.sql

Pre-commit / Pre-push Hook

Run pgfence init to automatically install a git hook. pgfence detects whether you use Husky or standard .git/hooks/.

bash
pgfence init

To use a pre-push hook instead of pre-commit:

bash
# Standard Git
mv .git/hooks/pre-commit .git/hooks/pre-push

# Husky
mv .husky/pre-commit .husky/pre-push

Requirements

  • Node.js 20 or later
  • PostgreSQL 14 assumed by default for version-sensitive checks (configurable)