File size: 1,314 Bytes
fc76af0 60cc4ec 4674427 2333542 fc76af0 60cc4ec fc76af0 60cc4ec fc76af0 2333542 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, Float, ARRAY, DateTime
from sqlalchemy.orm import relationship
from core.database import Base
from datetime import datetime
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
email = Column(String, unique=True, index=True, nullable=False)
password = Column(String, nullable=False)
first_name = Column(String, nullable=True)
last_name = Column(String, nullable=True)
age = Column(Integer, nullable=True)
preferences = Column(ARRAY(String), nullable=True)
is_active = Column(Boolean, default=True)
is_admin = Column(Boolean, default=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
created_at = Column(DateTime, default=datetime.utcnow)
orders = relationship("Order", back_populates="user")
embeddings = relationship("UserEmbeddings", back_populates="user", uselist=False)
class UserEmbeddings(Base):
__tablename__ = "user_embeddings"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"), unique=True, nullable=False)
embeddings = Column(ARRAY(Float), nullable=False)
user = relationship("User", back_populates="embeddings")
|