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

from app.infrastructure.database.models import Base


class TotalOrder(Base):
    __tablename__ = 'total_orders'

    id = Column(Integer, primary_key=True, autoincrement=True)
    order_datetime = Column(DateTime, nullable=False)
    count_robots = Column(Integer, nullable=False)
    deadline = Column(DateTime)
    price = Column(Float, nullable=False)

    user_id = Column(Integer, ForeignKey('users.id'))
    status_id = Column(Integer, ForeignKey('statuses.id'))

    user = relationship('User', back_populates='total_orders')
    status = relationship('Status', back_populates='total_orders')

    delivery_orders = relationship('DeliveryOrder', back_populates='total_order')
