Spaces:
Sleeping
Sleeping
| from sqlalchemy import Column, String, Boolean, DateTime, Text, ForeignKey | |
| from sqlalchemy.dialects.postgresql import UUID | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| import uuid | |
| from app.database import Base | |
| class Notification(Base): | |
| __tablename__ = "notifications" | |
| id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) | |
| user_id = Column( | |
| UUID(as_uuid=True), | |
| ForeignKey("users.id", ondelete="CASCADE"), | |
| nullable=False, | |
| index=True | |
| ) | |
| # Content | |
| title = Column(String(255), nullable=False) | |
| message = Column(Text, nullable=False) | |
| type = Column(String(50)) # job_alert, roadmap_reminder, interview_reminder, achievement | |
| # Action | |
| action_url = Column(Text) | |
| action_text = Column(String(100)) | |
| # Status | |
| is_read = Column(Boolean, default=False, index=True) | |
| read_at = Column(DateTime) | |
| # Timestamp | |
| created_at = Column(DateTime, server_default=func.now(), index=True) | |
| # Relationship | |
| user = relationship("User", back_populates="notifications") | |
| def __repr__(self): | |
| return f"<Notification {self.title}>" | |