class Clinic(Base):
'''Таблица клиники'''
id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True, nullable=False, comment="Наименование")
website = Column(String, comment="Веб-сайт")
phone = Column(String(21), comment="Телефон")
address = Column(String(500), comment="Адрес")
logo = Column(String(200), comment="Логотип")
start_time = Column(Time, comment="Начало рабочего дня")
end_time = Column(Time, comment="Конец рабочего дня")
rate_id = Column(Integer, ForeignKey("rate.id"))
users = relationship("User", back_populates="clinic")
rate = relationship("Rate", back_populates="clinics")
class Rate(Base):
'''Таблица с тарифами'''
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(50), unique=True, nullable=False, comment="Наименование")
price = Column(Integer, nullable=False, comment="Стомость")
is_active = Column(Boolean, default=True, comment="Активный")
clinics = relationship("Clinic", back_populates="rate")
class User(Base):
'''Модель пользователя'''
id = Column(Integer, primary_key=True, index=True)
first_name = Column(String, index=True)
last_name = Column(String, index=True)
patronymic = Column(String, index=True)
birthday = Column(Date)
image = Column(String, nullable=True)
email = Column(String, unique=True, index=True, nullable=False)
hashed_password = Column(String, nullable=False)
is_active = Column(Boolean(), default=True)
is_superuser = Column(Boolean(), default=False)
clinic_id = Column(Integer, ForeignKey('clinic.id'))
clinic = relationship("Clinic", back_populates="users")