Skip to content

Replace the PermissionModel reference table with an enum #7850

Description

@khvn26

permissions.PermissionModel is a reference table holding the fixed set of permission types. Its rows are seeded by data migrations spread across three apps. Permission assignments are M2M foreign keys to it. This breaks tests, and forces us to maintain unneeded complexity.

Proposal

Model permissions as an enum / constant set in code (key, description, type) and store assignments by key directly (e.g. a choices field on the through tables, or an array of keys), dropping the PermissionModel table. The set is fixed, so it does not belong in a mutable table.

Blast radius

  • The shared permissions M2M base and every model that inherits it (OSS: environments, environments/permissions, organisations/permissions, projects), plus the Role*Permission models in flagsmith-private/rbac.
  • A data migration converting existing permissionmodel_id links across all those through tables to the new representation.
  • The permissions API exposes ("key", "description", "supports_tag"), so descriptions and the tag-support flag must keep being served from the enum definition.

Acceptance

  • PermissionModel removed; permissions represented as an enum/constant set.
  • api/core/db_backends/postgresql/ and the DATABASES["default"]["ENGINE"] override in app/settings/test.py are deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions