18 lines
810 B
Python
18 lines
810 B
Python
from sqlalchemy import Boolean, Column, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
from app.models.base import Base, TimestampMixin
|
|
|
|
class User(Base, TimestampMixin):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String(255), unique=True, index=True, nullable=False)
|
|
username = Column(String(255), unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String(255), nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
is_superuser = Column(Boolean, default=False)
|
|
|
|
# Relationships
|
|
knowledge_bases = relationship("KnowledgeBase", back_populates="user")
|
|
chats = relationship("Chat", back_populates="user")
|
|
api_keys = relationship("APIKey", back_populates="user", cascade="all, delete-orphan") |