Registry / devops / pg-rls-util

pg-rls-util

JSON →
library0.0.41jsnpmunverified

pg-rls-util is a CLI tool that generates PostgreSQL Row-Level Security (RLS) policies based on configuration files. It supports generating scripts for tables, functions, roles, and ownership. Current stable version is 0.0.41, with infrequent releases. Key differentiators include automated generation from database introspection, diff capability, and support for multiple schemas and profiles. It is designed for PostgreSQL projects with complex RLS requirements, such as Graphile Starter setups.

npm install pg-rls-util
INSTALL
IMPORT
SIG · PG-RLS-UTIL
P
pg-rls-util
devopsjavascriptv0.0.41
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI tool
npx pg-rls-util init ...
npm install -g pg-rls-util && pg-rls-util init
npx is recommended for one-off usage; global install may cause version conflicts.
Module import
Not applicable - CLI only, no programmatic API.
const pgRlsUtil = require('pg-rls-util');
This package is a CLI tool and does not export any modules for programmatic use.

Initialize the project by connecting to a PostgreSQL database, introspecting schemas, and creating configuration files.

npx pg-rls-util init -x -c postgres://user:pass@localhost:5432/mydb -s app_public,app_private -p myproject
Debug
Known issues
gotchaThe CLI currently has limited documentation for complex profile configurations.
fix
Review the generated JSON files and edit them according to your security requirements.
affects: >=0.0.1
gotchaThe generated 'remove-all-rls.sql' script will drop ALL existing RLS policies across the entire database.
fix
Review this script before executing; consider backing up policies.
affects: >=0.0.1
breakingVersions prior to 0.0.31 may have incompatible configuration file formats.
fix
Upgrade to >=0.0.31 and regenerate configuration.
affects: <0.0.31
deprecatedThe 'script-templates.json' file is poorly formatted and may be removed in future versions.
fix
Do not rely on script-templates.json; prefer direct editing of security profiles.
affects: >=0.0.1
Errors
Common errors & fixes
Error: connect ECONNREFUSED
PostgreSQL server not running or connection string incorrect.
fix
Ensure PostgreSQL is running and connection string is correct: postgres://user:pass@host:port/db
Error: Cannot find module 'pg'
Missing dependency 'pg' npm package.
fix
Install 'pg' locally: npm install pg
no such file or directory, open 'pg-rls-util-gen/current-draft/roles.json'
Run 'init' before 'generate'.
fix
Run 'npx pg-rls-util init' first to create configuration files.
Upgrade
Version history
0.0.41latest on npm
Audit
Dependencies
postgresqlrequiredUsed to connect and introspect the database; requires a running PostgreSQL instance.
Agent activity
12 hits · last 30 days
node
12
Resources
pg-rls-util — npm install pg-rls-util · libregistry