Coverage for polar/models/notification.py: 88%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 12:42 +0000

1from typing import TYPE_CHECKING 

2from uuid import UUID 

3 

4from sqlalchemy import ForeignKey, String, Uuid 

5from sqlalchemy.dialects.postgresql import JSONB 

6from sqlalchemy.orm import Mapped, mapped_column, relationship 

7 

8from polar.kit.db.models import RecordModel 

9from polar.types import JSONDict 

10 

11if TYPE_CHECKING: 11 ↛ 12line 11 didn't jump to line 12 because the condition on line 11 was never true

12 from polar.models import User 

13 

14 

15class Notification(RecordModel): 

16 __tablename__ = "notifications" 

17 

18 user_id: Mapped[UUID] = mapped_column( 

19 Uuid, ForeignKey("users.id", ondelete="cascade"), nullable=False, index=True 

20 ) 

21 type: Mapped[str] = mapped_column(String, nullable=False) 

22 payload: Mapped[JSONDict] = mapped_column(JSONB, nullable=False, default=dict) 

23 

24 user: Mapped["User"] = relationship("User", lazy="raise")