flip_api.db.seed.roles
Attributes
Classes
A predefined role to seed; |
Functions
|
Seed roles into the database, idempotently. |
Module Contents
- class flip_api.db.seed.roles.RoleSeed
Bases:
TypedDictA predefined role to seed;
idis the stableRoleRefidentity.- id: uuid.UUID
- name: str
- description: str
- flip_api.db.seed.roles.seed_roles(session: sqlmodel.Session) list[str]
Seed roles into the database, idempotently.
Idempotency is keyed on the role
id(the stableRoleRef), not the name. A role may be renamed across releases while keeping its id — e.g. theobserver→viewerrename — so matching on the (mutable) name would miss the existing row and collide on the primary key when re-seeding a live database. An existing role has its name/description refreshed in place (bumpingupdated_at) so renames apply; an unchanged re-seed is left untouched.- Parameters:
session (Session) – The SQLModel session used for reads and writes.
- Returns:
All role names present after seeding.
- Return type:
list[str]