SnapFeast / users /models.py
Testys's picture
Adding migrations from alembic
d6866b9
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")