from sqlalchemy import Column, Integer, String, Boolean, JSON, Float
from app.db.base import Base

class EmailProviderConfig(Base):
    __tablename__ = "email_provider_configs"
    __table_args__ = {"schema": "data"}

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(50), unique=True) # Pl: SendGrid_Main, Office365_Backup
    provider_type = Column(String(20))     # SENDGRID, SMTP, MAILGUN
    priority = Column(Integer, default=1)  # 1 = legfontosabb
    
    # JSON-ban tároljuk a paramétereket (host, port, api_key, user, stb.)
    settings = Column(JSON, nullable=False)
    
    is_active = Column(Boolean, default=True)
    
    # Failover figyelés
    fail_count = Column(Integer, default=0)
    max_fail_threshold = Column(Integer, default=3) # Hány hiba után kapcsoljon le?
    success_rate = Column(Float, default=100.0)      # Statisztika az adminnak
