from sqlalchemy import Column, Integer, ForeignKey
from sqlalchemy.orm import relationship

from app.domain.models.base import BaseModel
from app.settings import settings


class MailingOption(BaseModel):
    __tablename__ = 'mailing_options'
    __table_args__ = {"schema": settings.SCHEMA}

    option_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing_delivery_methods.id'), nullable=False)
    mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id'), nullable=False)

    method = relationship('MailingDeliveryMethod', back_populates='mailing')
    mailing = relationship('Mailing', back_populates='mailing_options')
