cg-gen-ai / app /sql /models.py
khawir's picture
Start Application
c053e7d
raw
history blame
978 Bytes
from datetime import datetime
from app.sql.database import Base
from sqlalchemy.orm import relationship
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
class User(Base):
__tablename__ = 'users'
user_id = Column(Integer, primary_key=True, index=True)
username = Column(String, index=True, unique=True)
password = Column(String)
is_superuser = Column(Boolean, default=False)
is_active = Column(Boolean, default=True)
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
prompts = relationship("Prompt", back_populates="user")
class Prompt(Base):
__tablename__ = 'prompts'
id = Column(Integer, primary_key=True)
prompt = Column(String, index=True)
created_at = Column(DateTime, default=datetime.now)
user_id = Column(Integer, ForeignKey('users.user_id'))
user = relationship("User", back_populates="prompts")