初始提交:极码 GeekCode 全栈项目(FastAPI + Vue3)
This commit is contained in:
17
backend/models/follow.py
Normal file
17
backend/models/follow.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""关注关系模型"""
|
||||
from sqlalchemy import Column, Integer, DateTime, ForeignKey, UniqueConstraint
|
||||
from sqlalchemy.sql import func
|
||||
from database import Base
|
||||
|
||||
|
||||
class Follow(Base):
|
||||
__tablename__ = "follows"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
follower_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
following_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("follower_id", "following_id", name="uq_follow"),
|
||||
)
|
||||
Reference in New Issue
Block a user