zhibo/follow_record_table.sql
2026-01-03 15:32:31 +08:00

31 lines
2.0 KiB
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.

-- 关注记录表(用于用户之间的关注关系)
CREATE TABLE IF NOT EXISTS `eb_follow_record` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`follower_id` int(11) NOT NULL COMMENT '关注者用户ID',
`follower_nickname` varchar(50) DEFAULT NULL COMMENT '关注者昵称',
`follower_phone` varchar(20) DEFAULT NULL COMMENT '关注者手机号',
`followed_id` int(11) NOT NULL COMMENT '被关注者用户ID',
`followed_nickname` varchar(50) DEFAULT NULL COMMENT '被关注者昵称',
`followed_phone` varchar(20) DEFAULT NULL COMMENT '被关注者手机号',
`follow_status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '关注状态1-已关注 0-已取消',
`is_deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '逻辑删除0-未删除 1-已删除',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`ext_field1` varchar(100) DEFAULT NULL COMMENT '扩展字段1关注来源/渠道',
`ext_field2` int(11) DEFAULT NULL COMMENT '扩展字段2关注类型/优先级',
`ext_field3` varchar(200) DEFAULT NULL COMMENT '扩展字段3特殊标记/备注',
`ext_field4` bigint(20) DEFAULT NULL COMMENT '扩展字段4关联数据ID',
`ext_field5` text COMMENT '扩展字段5JSON扩展数据',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_follower_followed` (`follower_id`,`followed_id`),
KEY `idx_follower_id` (`follower_id`),
KEY `idx_followed_id` (`followed_id`),
KEY `idx_follow_status` (`follow_status`),
KEY `idx_is_deleted` (`is_deleted`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='关注记录表';
-- 如果已有 eb_user_follow 表的数据,可以迁移到新表
-- INSERT INTO eb_follow_record (follower_id, followed_id, follow_status, is_deleted, create_time)
-- SELECT user_id, follow_user_id, 1, 0, create_time FROM eb_user_follow;