Skip to content

Add --skip-privileges flag to skip table privilege diffing#275

Open
kjanoudi wants to merge 1 commit intostripe:mainfrom
Cheddar-Up:add-skip-privileges-flag
Open

Add --skip-privileges flag to skip table privilege diffing#275
kjanoudi wants to merge 1 commit intostripe:mainfrom
Cheddar-Up:add-skip-privileges-flag

Conversation

@kjanoudi
Copy link
Copy Markdown

Summary

Adds a WithSkipTablePrivileges() plan option and corresponding --skip-privileges CLI flag that strips table privileges from both the source and target schemas before diffing. This allows plan generation to succeed when partitioned tables have privileges, which otherwise fails with:

privileges on partitions: not implemented

Motivation

After #264 introduced table privilege support, databases with partitioned tables that have privileges assigned (e.g., via GRANT) cannot generate migration plans. The privilege diff logic does not yet support partitions, so any privilege present on a partition causes plan generation to fail.

This flag provides a workaround: users who don't need privilege diffing can skip it entirely, unblocking plan generation for schemas with partitioned tables.

Fixes #269

Changes

  • pkg/diff/plan_generator.go: Added skipTablePrivileges field to planOptions and WithSkipTablePrivileges() exported option function. When enabled, calls the existing clearTablePrivileges() helper on both schemas before generating migration statements.
  • cmd/pg-schema-diff/plan_cmd.go: Added --skip-privileges boolean CLI flag wired to the new plan option.

Test plan

  • go build ./... passes
  • go vet ./... passes
  • --help output shows the new flag with description
  • The implementation reuses the existing clearTablePrivileges() function (already used in plan validation) so the privilege-stripping behavior is well-established

Add WithSkipTablePrivileges() plan option and --skip-privileges CLI flag
that strips table privileges from both schemas before diffing. This allows
plan generation to succeed when partitioned tables have privileges, which
otherwise fails with "privileges on partitions: not implemented".

Fixes stripe#269
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Mar 30, 2026

CLA assistant check
All committers have signed the CLA.

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.

Add --no-privileges flag to exclude GRANT/REVOKE from plan/apply

1 participant