Coverage for polar/models/event_type.py: 89%
17 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 17:15 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 17:15 +0000
1from typing import TYPE_CHECKING 1ab
2from uuid import UUID 1ab
4from sqlalchemy import ForeignKey, String, UniqueConstraint, Uuid 1ab
5from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship 1ab
7from polar.kit.db.models.base import RecordModel 1ab
9if TYPE_CHECKING: 9 ↛ 10line 9 didn't jump to line 10 because the condition on line 9 was never true1ab
10 from .organization import Organization
13class EventType(RecordModel): 1ab
14 __tablename__ = "event_types" 1ab
15 __table_args__ = ( 1ab
16 UniqueConstraint(
17 "name",
18 "organization_id",
19 name="event_types_name_organization_id_key",
20 ),
21 )
23 name: Mapped[str] = mapped_column(String(128), nullable=False, index=True) 1ab
24 label: Mapped[str] = mapped_column(String(128), nullable=False) 1ab
25 label_property_selector: Mapped[str | None] = mapped_column( 1ab
26 String(256), nullable=True
27 )
29 organization_id: Mapped[UUID] = mapped_column( 1ab
30 Uuid,
31 ForeignKey("organizations.id", ondelete="cascade"),
32 nullable=False,
33 index=True,
34 )
36 @declared_attr 1ab
37 def organization(cls) -> Mapped["Organization"]: 1ab
38 return relationship("Organization", lazy="raise") 1ab