22 lines
862 B
Python
22 lines
862 B
Python
|
|
"""User model."""
|
||
|
|
from sqlalchemy import Column, Integer, String, DateTime
|
||
|
|
from sqlalchemy.orm import relationship
|
||
|
|
from datetime import datetime
|
||
|
|
from app.database import Base
|
||
|
|
|
||
|
|
class User(Base):
|
||
|
|
"""User model."""
|
||
|
|
__tablename__ = "users"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True, index=True)
|
||
|
|
email = Column(String(255), unique=True, index=True, nullable=False)
|
||
|
|
username = Column(String(100), unique=True, index=True, nullable=False)
|
||
|
|
hashed_password = Column(String(255), nullable=False)
|
||
|
|
full_name = Column(String(255))
|
||
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||
|
|
is_active = Column(Integer, default=1)
|
||
|
|
|
||
|
|
workspaces = relationship("Workspace", back_populates="owner")
|
||
|
|
comments = relationship("Comment", back_populates="author")
|