Add parent WeChat identity mapping

This commit is contained in:
stu2not
2026-06-25 18:53:01 +08:00
parent 10c43a5338
commit a2b873a3c2
6 changed files with 697 additions and 6 deletions

View File

@@ -245,6 +245,25 @@ class ParentWechatAccount(Base):
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
class ParentWechatIdentity(Base):
__tablename__ = "parent_wechat_identities"
__table_args__ = (
UniqueConstraint("app_id", "account_type", "openid", name="uq_parent_wechat_identity_app_openid"),
Index("idx_parent_wechat_identity_user", "user_id"),
Index("idx_parent_wechat_identity_unionid", "unionid"),
{'mysql_charset': 'utf8mb4', 'mysql_collate': 'utf8mb4_unicode_ci'}
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("parents.user_id"), nullable=False)
app_id: Mapped[str] = mapped_column(String(64), nullable=False)
account_type: Mapped[str] = mapped_column(String(32), nullable=False)
openid: Mapped[str] = mapped_column(String(64), nullable=False)
unionid: Mapped[Optional[str]] = mapped_column(String(64))
created_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
class WechatMpBindState(Base):
__tablename__ = "wechat_mp_bind_states"
__table_args__ = (