discard adjustable models' id prefix & payload length

This commit is contained in:
2026-05-19 01:54:06 +08:00
parent 86b030930c
commit b58f74d59b
6 changed files with 21 additions and 45 deletions
+2 -9
View File
@@ -1,25 +1,18 @@
from typing import TYPE_CHECKING
from sqlalchemy import Column, DateTime, String, ForeignKey, UniqueConstraint
from sqlalchemy.sql import func
from .base import AutoID, Base
# 只有在静态检查时才导入
# 运行阶段这段代码会被跳过,彻底避免循环导入
# 不确定是否用得上,但感觉这是个好习惯,尤其在模型之间有外键关系时
if TYPE_CHECKING:
from .user import User
class Follow(Base, AutoID):
"""用户关注关系表"""
__tablename__ = "follows"
follower_id = Column(
String(User.id_length()),
String(AutoID.id_length()),
ForeignKey("users.id", ondelete="CASCADE"),
index=True
)
followee_id = Column(
String(User.id_length()),
String(AutoID.id_length()),
ForeignKey("users.id", ondelete="CASCADE"),
index=True
)