from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Text from sqlalchemy.orm import relationship from sqlalchemy.sql import func from ..database import Base class Notification(Base): """User notifications""" __tablename__ = "notifications" id = Column(Integer, primary_key=True, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False) # Notification type: vehicle_recommended, shipping_update, withdrawal_processed, # referral_reward, dealer_approved, share_purchased, system notification_type = Column(String(50), nullable=False) # Title and message (supports i18n keys or direct text) title = Column(String(200), nullable=False) message = Column(Text, nullable=False) # Optional link to navigate when clicked link = Column(String(500), nullable=True) # Related entity (optional) related_id = Column(Integer, nullable=True) # ID of related entity related_type = Column(String(50), nullable=True) # Type: vehicle_request, purchased_vehicle, withdrawal, etc. # Status is_read = Column(Boolean, default=False) read_at = Column(DateTime(timezone=True), nullable=True) # Timestamps created_at = Column(DateTime(timezone=True), server_default=func.now()) # Relationships user = relationship("User", backref="notifications")