32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from sqlalchemy import Boolean, ForeignKey, JSON, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from cpv3.db.base import Base, BaseModelMixin
|
|
|
|
|
|
class Notification(Base, BaseModelMixin):
|
|
__tablename__ = "notifications"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), index=True
|
|
)
|
|
job_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("jobs.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
project_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("projects.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
)
|
|
|
|
notification_type: Mapped[str] = mapped_column(String(32))
|
|
title: Mapped[str] = mapped_column(String(255))
|
|
message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
payload: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
is_read: Mapped[bool] = mapped_column(Boolean, default=False)
|