spark-server/migrations/0033_user_follows.sql
DESKTOP-L8OUL9F\gfl0034 ce9c7a13aa feat: 互相关注后自动成为好友
一方关注只记关注。双方互关时写入已有双向好友边;取消关注若不再互关只删好友边,不删消息。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-18 21:51:18 +08:00

12 lines
681 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- One directed follow per pair. Mutual follows become friend edges in logic; unfollowing does not delete messages.
CREATE TABLE IF NOT EXISTS t_user_follows (
id BIGINT NOT NULL AUTO_INCREMENT COMMENT '行 id,表内自增',
user_id BIGINT NOT NULL COMMENT '关注人 user_id',
target_id BIGINT NOT NULL COMMENT '被关注人 user_id',
created_at DATETIME(3) NOT NULL COMMENT '关注时间',
PRIMARY KEY (id),
UNIQUE KEY uk_user_target (user_id, target_id),
KEY idx_target (target_id)
) COMMENT='单向关注。双方互相关注时写入已有双向好友边;取消关注只删关注,不再互关时删好友边,不删消息';