"""This module defines the SQL data model for users.""" from sqlalchemy import Column, Integer, String, DateTime from sqlalchemy.sql.functions import now from sqlalchemy.orm import relationship from todo.database.engine import Base class User(Base): """Model for the users table.""" __tablename__ = "users" id = Column('id', Integer, primary_key=True, autoincrement=True, index=True) email = Column('email', String, unique=True, nullable=False, index=True) password = Column('password', String, nullable=False) created = Column('created', DateTime(timezone=True), nullable=False, server_default=now()) updated = Column('updated', DateTime(timezone=True), nullable=False, server_default=now(), onupdate=now()) first_name = Column('first_name', String, nullable=False) last_name = Column('last_name', String, nullable=False, index=True) todo_items = relationship("TodoItem", back_populates="user", uselist=True, cascade="all, delete")