Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions core/orm/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ class KeywordReply(orm.Base):
reply_type: Mapped[str] = Column(String(length=10), nullable=False)
reply: Mapped[str] = Column(Text, nullable=False)
reply_md5: Mapped[str] = Column(String(length=32), primary_key=True)


class TarotRecord(orm.Base):
"""塔罗牌占卜记录"""

__tablename__ = "tarot_record"

id: Mapped[int] = Column(Integer, primary_key=True)
user_id: Mapped[int] = Column(BIGINT, nullable=False)
group_id: Mapped[int] = Column(BIGINT, nullable=False)
divination_type: Mapped[str] = Column(
String(length=20),
nullable=False,
info={"check": ["daily_fortune", "three_card", "celtic_cross"]}
)
Comment on lines +100 to +102
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check constraint syntax is incorrect for SQLAlchemy. The info parameter doesn't create database constraints. Use CheckConstraint from sqlalchemy to properly validate divination_type values.

Suggested change
nullable=False,
info={"check": ["daily_fortune", "three_card", "celtic_cross"]}
)
nullable=False
)
__table_args__ = (
CheckConstraint(
"divination_type IN ('daily_fortune', 'three_card', 'celtic_cross')",
name="ck_tarotrecord_divination_type"
),
)

Copilot uses AI. Check for mistakes.
divination_time: Mapped[DateTime] = Column(DateTime, nullable=False)
cards_drawn: Mapped[str] = Column(Text, nullable=False) # JSON string of card results
card_positions: Mapped[str] = Column(Text, nullable=True) # JSON string of upright/reverse positions
Loading