Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements support for PostgreSQL's FORCE ROW LEVEL SECURITY feature, which applies RLS policies even to table owners and superusers. The implementation adds a new RLSForced boolean field to track this state alongside the existing RLSEnabled field, updates database queries to fetch the relforcerowsecurity column, and extends the diff/migration logic to handle ENABLE/FORCE changes independently.
Key changes:
- Added
RLSForcedfield to the IR Table struct to track forced RLS state - Updated database queries to fetch both
relrowsecurityandrelforcerowsecurityfrompg_catalog.pg_class - Modified diff logic to handle ENABLE and FORCE RLS changes as separate, independent operations using pointer fields to distinguish between "no change" and "change to false"
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| testdata/diff/create_policy/force_rls/* | New test case validating FORCE RLS detection and migration from enabled-only to enabled-and-forced state |
| testdata/diff/create_policy/*/plan.json | Updated fingerprint hashes to account for new RLSForced field in IR |
| ir/ir.go | Added RLSForced boolean field to Table struct |
| ir/queries/queries.sql | Modified RLS table queries to fetch relforcerowsecurity and changed to use pg_catalog.pg_class instead of pg_tables |
| ir/queries/queries.sql.go | Generated code reflecting query changes, including simplified parameter types |
| ir/inspector.go | Updated buildRLSPolicies to set both RLSEnabled and RLSForced from query results |
| internal/diff/diff.go | Modified rlsChange struct to use pointer fields for Enabled and Forced to distinguish no-change from change-to-false |
| internal/diff/policy.go | Extended generateRLSChangesSQL to handle both ENABLE/DISABLE and FORCE/NO FORCE statements independently |
| internal/diff/table.go | Updated diff detection and SQL generation logic to track and generate both ENABLE and FORCE changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Implements PostgreSQL's FORCE ROW LEVEL SECURITY feature, which applies row-level security policies even to table owners and superusers. Changes: - Added RLSForced boolean field to IR Table struct - Updated database queries to fetch relforcerowsecurity from pg_class - Extended diff logic to track ENABLE and FORCE changes independently - Added SQL generation for FORCE/NO FORCE ROW LEVEL SECURITY statements - Created dedicated test case for FORCE RLS functionality - Updated fingerprints in existing policy tests to account for new IR field Test coverage: - New test: create_policy/force_rls - validates FORCE RLS detection and migration - All 9 policy integration tests passing - Both diff and plan/apply tests validated Fixes #214 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
alecthomas
pushed a commit
to alecthomas/pgschema
that referenced
this pull request
Jan 26, 2026
* feat: add support for FORCE ROW LEVEL SECURITY Implements PostgreSQL's FORCE ROW LEVEL SECURITY feature, which applies row-level security policies even to table owners and superusers. Changes: - Added RLSForced boolean field to IR Table struct - Updated database queries to fetch relforcerowsecurity from pg_class - Extended diff logic to track ENABLE and FORCE changes independently - Added SQL generation for FORCE/NO FORCE ROW LEVEL SECURITY statements - Created dedicated test case for FORCE RLS functionality - Updated fingerprints in existing policy tests to account for new IR field Test coverage: - New test: create_policy/force_rls - validates FORCE RLS detection and migration - All 9 policy integration tests passing - Both diff and plan/apply tests validated Fixes pgplex#214 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: regenerate plan --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements PostgreSQL's FORCE ROW LEVEL SECURITY feature, which applies row-level security policies even to table owners and superusers.
Changes:
Test coverage:
Fixes #214
🤖 Generated with Claude Code