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-utilNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize the project by connecting to a PostgreSQL database, introspecting schemas, and creating configuration files.
Review the generated JSON files and edit them according to your security requirements.
Review this script before executing; consider backing up policies.
Upgrade to >=0.0.31 and regenerate configuration.
Do not rely on script-templates.json; prefer direct editing of security profiles.
Ensure PostgreSQL is running and connection string is correct: postgres://user:pass@host:port/db
Install 'pg' locally: npm install pg
Run 'npx pg-rls-util init' first to create configuration files.