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

from app.infrastructure.database.models import Base


class User(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True, autoincrement=True)
    first_name = Column(VARCHAR(100), nullable=False)
    last_name = Column(VARCHAR(100), nullable=False)
    login = Column(VARCHAR(150), nullable=False)
    password = Column(VARCHAR(500), nullable=False)

    role_id = Column(Integer, ForeignKey('roles.id'))

    role = relationship('Role', back_populates='users')

    total_orders = relationship('TotalOrder', back_populates='user')
