1.7
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""默契种子模型"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import String, Integer, DateTime, ForeignKey, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class SyncQuestion(Base):
|
||||
__tablename__ = "sync_questions"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True)
|
||||
content: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
active_date: Mapped[str | None] = mapped_column(String(10), nullable=True) # YYYY-MM-DD
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.utcnow())
|
||||
|
||||
|
||||
class SyncSeed(Base):
|
||||
"""默契种子:两人对同一题的作答"""
|
||||
__tablename__ = "sync_seeds"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("question_id", "user_a", "user_b", name="uq_sync_seed_pair"),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True)
|
||||
question_id: Mapped[str] = mapped_column(String(36), ForeignKey("sync_questions.id", ondelete="CASCADE"))
|
||||
user_a: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"))
|
||||
user_b: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"))
|
||||
answer_a: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
||||
answer_b: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
||||
score: Mapped[int | None] = mapped_column(Integer, nullable=True) # 0-100
|
||||
leaf_seed: Mapped[str | None] = mapped_column(String(16), nullable=True) # 默契叶种子
|
||||
status: Mapped[str] = mapped_column(String(20), default="draft") # draft/revealed
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.utcnow())
|
||||
revealed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
Reference in New Issue
Block a user