17 lines
691 B
Python
17 lines
691 B
Python
from sqlalchemy import Column, Integer, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.domain.models.base import BaseModel
|
|
from app.settings import settings
|
|
|
|
|
|
class Recipient(BaseModel):
|
|
__tablename__ = 'recipients'
|
|
__table_args__ = {"schema": settings.SCHEMA}
|
|
|
|
patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False)
|
|
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
|
|
|
patient = relationship('Patient', back_populates='mailing', cascade="all, delete")
|
|
mailing = relationship('Mailing', back_populates='recipients', cascade="all, delete")
|