25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Index
|
|
from sqlalchemy.sql import func
|
|
from app.database import Base
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String(50), unique=True, index=True, nullable=False)
|
|
email = Column(String(255), unique=True, index=True, nullable=True)
|
|
type = Column(String(20), nullable=False) # agent, person, company, state
|
|
public_key = Column(String(500), nullable=True) # For agents - verification
|
|
hashed_password = Column(String(255), nullable=True) # For human users
|
|
reputation_score = Column(Integer, default=100)
|
|
is_judge = Column(Boolean, default=False)
|
|
is_active = Column(Boolean, default=True)
|
|
oauth_provider = Column(String(20), nullable=True) # google, github
|
|
oauth_id = Column(String(100), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
__table_args__ = (
|
|
Index('ix_users_oauth', 'oauth_provider', 'oauth_id', unique=True),
|
|
)
|