feat(groups): chat_group改复合主键(channel,owner,room)——多员工同群不再去重(云客张士蓓64群vs原42)

原 room_id 单列 PK 把多员工同群合并成一行(末位覆盖owner),其他员工
群列表缺数据。改复合主键后同群每个员工各一行,对齐云客按员工查看。
重扫后 1590 行/865 去重群/张士蓓 64 群(与云客一致)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-24 12:01:25 +08:00
parent 847c4cdee4
commit 8a99940554
+4 -4
View File
@@ -269,12 +269,12 @@ class ChatGroup(Base):
__tablename__ = "chat_group"
# 复合主键(channel, owner, room):同一群在每个员工名下各一行(2026-08-24)
# 原按 room_id 单列 PK 会把多员工同群去重(云客张士蓓 64 群 vs 我们 42)
room_id: Mapped[str] = mapped_column(String(128), primary_key=True)
channel: Mapped[str] = mapped_column(String(16), nullable=False)
channel: Mapped[str] = mapped_column(String(16), primary_key=True)
owner_account_id: Mapped[str] = mapped_column(String(128), primary_key=True)
room_name: Mapped[str | None] = mapped_column(String(255), nullable=True)
owner_account_id: Mapped[str | None] = mapped_column(
String(128), nullable=True
) # wechatId / uid of owning staff account
owner_account_nickname: Mapped[str | None] = mapped_column(
String(255), nullable=True
)