26 lines
969 B
Python
26 lines
969 B
Python
"""This module defines the SQL data model for users."""
|
|
|
|
import enum
|
|
|
|
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)
|
|
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)
|
|
|
|
todo_items = relationship("TodoItem", back_populates="user", uselist=True, cascade="all, delete")
|