Skip to content

Class tigrbl.orm.mixins.principals.OrgColumn

tigrbl.orm.mixins.principals.OrgColumn

Adds org_id with a schema-qualified FK to <schema>.orgs.id.

org_id

org_id()
Source code in tigrbl/orm/mixins/principals.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@declared_attr
def org_id(cls) -> Mapped[UUID]:
    schema = getattr(cls, "__org_table_schema__", None) or _infer_schema(cls)
    spec = ColumnSpec(
        storage=S(
            type_=PgUUID(as_uuid=True),
            fk=ForeignKeySpec(target=f"{schema}.orgs.id"),
            nullable=False,
            index=True,
        ),
        field=F(py_type=UUID, constraints={"examples": [uuid_example]}),
        io=CRUD_IO,
    )
    return acol(spec=spec)