Skip to content

fix(BA-5309): Add migration to convert global-scoped permissions to domain-scoped#10342

Merged
fregataa merged 3 commits into
mainfrom
BA-5309
Mar 20, 2026
Merged

fix(BA-5309): Add migration to convert global-scoped permissions to domain-scoped#10342
fregataa merged 3 commits into
mainfrom
BA-5309

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented Mar 20, 2026

Summary

  • Add Alembic migration to convert deprecated scope_type='global' permission rows to domain-scoped equivalents
  • For each global-scoped permission, creates one domain-scoped row per active domain (preserving role_id, entity_type, operation), then deletes the original global row
  • Uses ON CONFLICT DO NOTHING to handle cases where domain-scoped permissions already exist

Test plan

  • pants lint passes for changed files
  • pants check passes for manager package
  • pants test passes for RBAC and permission-related tests
  • Verify migration runs cleanly on a database with global-scoped permission rows

Resolves BA-5309

…omain-scoped

Replace deprecated scope_type='global' permission rows with
domain-scoped equivalents (one row per active domain), preserving
role_id, entity_type, and operation values. Uses ON CONFLICT DO NOTHING
to handle pre-existing domain-scoped permissions gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 20, 2026 02:18
@github-actions github-actions Bot added size:M 30~100 LoC comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated labels Mar 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Alembic migration to eliminate deprecated scope_type='global' rows in permissions by duplicating them as domain-scoped permissions (one per domain) and then deleting the original global rows. This supports the ongoing RBAC move away from “global” scope.

Changes:

  • Introduces a new Alembic revision to convert permissions.scope_type='global' into scope_type='domain' across domains.
  • Uses conflict-handling on the permissions uniqueness constraint to avoid duplicate inserts.
  • Leaves downgrade as a no-op (non-reversible conversion).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fregataa fregataa requested a review from ironAiken2 March 20, 2026 02:26
@fregataa fregataa added this to the 26.4 milestone Mar 20, 2026
- Change down_revision from ffcf0ed13a26 to 0e0723286a7a to resolve
  multiple Alembic heads and ensure unique constraint exists
- Filter domains by is_active to skip inactive domains
- Replace nested Python loop with single INSERT...SELECT CROSS JOIN

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fregataa fregataa merged commit bb6bb69 into main Mar 20, 2026
37 checks passed
@fregataa fregataa deleted the BA-5309 branch March 20, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants