|
|
|
|
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean |
|
from sqlalchemy.orm import relationship |
|
from sqlalchemy.sql import func |
|
from base import Base |
|
|
|
|
|
class User(Base): |
|
__tablename__ = "users" |
|
|
|
id = Column(Integer, primary_key=True, index=True) |
|
email = Column(String, unique=True, index=True) |
|
username = Column(String, unique=True, index=True, nullable=True) |
|
hashed_password = Column(String) |
|
is_verified = Column(Boolean, default=False) |
|
credits = Column(Integer, default=10000) |
|
selected_tts_models = Column(String, default='default.onnx') |
|
email_verification_token = Column(String, unique=True, nullable=True) |
|
|
|
|
|
verification_tokens = relationship("VerificationToken", back_populates="user") |
|
|
|
|
|
class VerificationToken(Base): |
|
__tablename__ = "verification_tokens" |
|
|
|
id = Column(Integer, primary_key=True, index=True) |
|
token = Column(String, unique=True, index=True) |
|
user_id = Column(Integer, ForeignKey('users.id'), nullable=False) |
|
created_at = Column(DateTime(timezone=True), server_default=func.now()) |
|
|
|
|
|
user = relationship("User", back_populates="verification_tokens") |