Skip to content

feat(pg-core): add .forceRLS() to pgTable builder#5843

Open
dmitrymaranik wants to merge 1 commit into
drizzle-team:mainfrom
dmitrymaranik:feat/pg-force-rls
Open

feat(pg-core): add .forceRLS() to pgTable builder#5843
dmitrymaranik wants to merge 1 commit into
drizzle-team:mainfrom
dmitrymaranik:feat/pg-force-rls

Conversation

@dmitrymaranik
Copy link
Copy Markdown

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 #5819

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add .forceRLS() to pgTable builder

1 participant