flip_api.db.seed.role_permissions
Functions
|
Grant a role a set of permissions, skipping pairs already present. |
|
Seed role/permission intersections. |
Module Contents
- flip_api.db.seed.role_permissions._grant_permissions(session: sqlmodel.Session, role_id: uuid.UUID, permission_ids: list[uuid.UUID]) None
Grant a role a set of permissions, skipping pairs already present.
Matches the check-then-insert idempotency pattern used by
seed_rolesandseed_permissions: avoids relying on IntegrityError recovery and stays DB-driver agnostic.- Parameters:
session (Session) – Database session.
role_id (UUID) – Role receiving the permissions.
permission_ids (list[UUID]) – Permissions to grant.
- Returns:
None
- flip_api.db.seed.role_permissions.seed_role_permissions(session: sqlmodel.Session) None
Seed role/permission intersections.
Idempotent: running against a populated DB inserts only the missing pairs. Does not remove permissions that have been taken out of the seed (that would need an explicit migration, not a seed).
Admin: every permission defined in
PermissionRef.Researcher:
CAN_CREATE_PROJECTSonly.CAN_MANAGE_PROJECTSis reserved for Admin — it bypasses per-project access checks (see issue #358).Viewer: none — read-only access is enforced at the route layer by the absence of
CAN_MANAGE_PROJECTS.
- Parameters:
session (Session) – Database session.
- Returns:
None