feat(pg-core): add .forceRLS() to pgTable builder#5843
Open
dmitrymaranik wants to merge 1 commit into
Open
Conversation
Adds a `.forceRLS()` modifier on the pgTable builder, a companion to the existing `.enableRLS()`. It emits `ALTER TABLE ... FORCE ROW LEVEL SECURITY` in the generated migration so that the table owner role is also subject to RLS policies. `.forceRLS()` implies `.enableRLS()`, since FORCE is a no-op unless RLS is enabled. drizzle-orm: - new `EnableForceRLS` symbol + `[EnableForceRLS]` flag on PgTable - `.forceRLS()` modifier and `forceRLS` on the PgTableWithColumns type - `getTableConfig` now returns `enableForceRLS` drizzle-kit: - thread `isForceRLSEnabled` through the pg snapshot (serializer, schema, squash) and the V6->V7 snapshot upgrade - diff the force toggle -> `force_rls` / `no_force_rls` json statements - `PgForceRlsConvertor` / `PgNoForceRlsConvertor` emit FORCE / NO FORCE - create-table appends FORCE after ENABLE when forceRLS is set - introspection reads `relforcerowsecurity` so pull round-trips the flag Tests: add forceRLS cases to drizzle-kit/tests/rls/pg-policy.test.ts covering create-table, toggling force on/off, and add-policy + force. Closes drizzle-team#5819
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.
Adds a
.forceRLS()modifier on the pgTable builder, a companion to the existing.enableRLS(). It emitsALTER TABLE ... FORCE ROW LEVEL SECURITYin the generated migration so that the table owner role is also subject to RLS policies..forceRLS()implies.enableRLS(), since FORCE is a no-op unless RLS is enabled.drizzle-orm:
EnableForceRLSsymbol +[EnableForceRLS]flag on PgTable.forceRLS()modifier andforceRLSon the PgTableWithColumns typegetTableConfignow returnsenableForceRLSdrizzle-kit:
isForceRLSEnabledthrough the pg snapshot (serializer, schema, squash) and the V6->V7 snapshot upgradeforce_rls/no_force_rlsjson statementsPgForceRlsConvertor/PgNoForceRlsConvertoremit FORCE / NO FORCErelforcerowsecurityso pull round-trips the flagTests: add forceRLS cases to drizzle-kit/tests/rls/pg-policy.test.ts covering create-table, toggling force on/off, and add-policy + force.
Closes #5819