feat(db): add role-based access grants for analytics schema#5279
Merged
feat(db): add role-based access grants for analytics schema#5279
Conversation
## Context This PR adds the ability to grant read access (USAGE + SELECT) on the analytics schema to a configurable PostgreSQL role after schema generation. This enables external analytics tools to query the sanitized views with a dedicated read-only database role even after each schema re-create. ### Workflow When `GENERATE_SANITIZED_SCHEMA=true`: 1. Drop schema (before migrations) - prevents dependency conflicts so that ALTER commands don't conflict with table that has views 2. Run migrations 3. Create schema and views 4. Grant access to role (if `SANITIZED_SCHEMA_ROLE` is configured) ### New Environment Variables When `SANITIZED_SCHEMA_ROLE` is defined it will grant read access to the analytics schema for the given role. ## Screenshots N/A - Backend changes only ## Type - [ ] Fix - [x] Feature - [ ] Improvement - [ ] Breaking - [ ] Docs - [ ] Chore ## Checklist - [x] Title follows the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format - [ ] Tested locally - [ ] Updated docs (if needed) - [x] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview)
Collaborator
Author
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Greptile OverviewGreptile SummaryThis PR adds the ability to grant read-only database access to the analytics schema via a configurable PostgreSQL role ( Major Changes:
Critical Security Issue:
Additional Notes:
Confidence Score: 1/5
Important Files Changed
|
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
akhilmhdh
approved these changes
Jan 27, 2026
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.
Context
This PR adds the ability to grant read access (USAGE + SELECT) on the analytics schema to a configurable PostgreSQL role after schema generation. This enables external analytics tools to query the sanitized views with a dedicated read-only database role even after each schema re-create.
Workflow
When
GENERATE_SANITIZED_SCHEMA=true:SANITIZED_SCHEMA_ROLEis configured)New Environment Variables
When
SANITIZED_SCHEMA_ROLEis defined it will grant read access to the analytics schema for the given role.Screenshots
N/A - Backend changes only
Type
Checklist