Skip to content

Commit

Permalink
Feat : Add DB table 구현
Browse files Browse the repository at this point in the history
- #4
  • Loading branch information
taeyang916 committed Feb 25, 2024
1 parent dc79960 commit c9e742e
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions backend/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from sqlalchemy import Boolean, Column, Integer, String, DateTime, ForeignKey, Float, Numeric
from database import Base
from typing import Optional
from passlib.context import CryptContext
from datetime import datetime

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

def hash_password(password: str):
return pwd_context.hash(password)

class User(Base):
__tablename__ = 'users'

id = Column(Integer, primary_key=True, index=True)
email = Column(String(50), unique=True)
password = Column(String(255))
age = Column(Integer)
gender = Column(Boolean) # 0: man, 1: woman
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
deleted_at = Column(DateTime, nullable=True, onupdate=datetime.utcnow)

class Request(Base):
__tablename__ = 'requests'

id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey('USERS.id'))
age = Column(Integer) # 0: man, 1: woman
gender = Column(Boolean)
voice_url = Column(String(255))
status = Column(Integer)
eta = Column(DateTime, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
deleted_at = Column(DateTime, nullable=True, onupdate=datetime.utcnow)

class Result(Base):
__tablename__ = 'results'

id = Column(Integer, primary_key=True, index=True)
request_id = Column(Integer, ForeignKey('REQUESTS.id'))

condition_image_url = Column(String(255), nullable=True)
condition_gif_url = Column(String(255), nullable=True)
voice_image_url = Column(String(255), numllable=True)
voice_gif_url = Column(String(255), numllable=True)

condition_image_rating = Column(Integer, nullable=True)
condition_gif_rating = Column(Integer, nullable=True)
voice_image_rating = Column(Integer, numllable=True)
voice_gif_rating = Column(Integer, numllable=True)

voice_image_score = Column(Float, nullable=True)
condition_gif_score = Column(Float, nullable=True)
voice_image_score = Column(Float, numllable=True)
voice_gif_score = Column(Float, numllable=True)

created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
deleted_at = Column(DateTime, nullable=True, onupdate=datetime.utcnow)

0 comments on commit c9e742e

Please sign in to comment.