feat: 为announcement表添加belong_id字段以关联代理商和公告
This commit is contained in:
23
src/main/resources/db_migration_add_belong_id.sql
Normal file
23
src/main/resources/db_migration_add_belong_id.sql
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- 为announcement表添加belong_id字段
|
||||||
|
-- 执行时间: ${DATE}
|
||||||
|
-- 描述: 为公告表添加归属用户ID字段,用于关联代理商和公告
|
||||||
|
|
||||||
|
-- 添加belong_id字段
|
||||||
|
ALTER TABLE announcement
|
||||||
|
ADD COLUMN belong_id INT UNSIGNED NULL DEFAULT NULL COMMENT '归属用户ID(代理商ID)'
|
||||||
|
AFTER jump_url;
|
||||||
|
|
||||||
|
-- 为belong_id字段添加索引,提升查询性能
|
||||||
|
CREATE INDEX idx_announcement_belong_id ON announcement (belong_id);
|
||||||
|
|
||||||
|
-- 添加外键约束,确保数据一致性(可选,根据实际需求决定是否启用)
|
||||||
|
-- ALTER TABLE announcement
|
||||||
|
-- ADD CONSTRAINT fk_announcement_belong_id
|
||||||
|
-- FOREIGN KEY (belong_id) REFERENCES user_account (id)
|
||||||
|
-- ON DELETE SET NULL ON UPDATE RESTRICT;
|
||||||
|
|
||||||
|
-- 更新说明:
|
||||||
|
-- 1. belong_id字段允许为NULL,表示系统级公告
|
||||||
|
-- 2. 当belong_id不为NULL时,表示该公告属于特定代理商
|
||||||
|
-- 3. 索引可以提升按belong_id查询的性能
|
||||||
|
-- 4. 外键约束已注释,如需要请取消注释并执行
|
||||||
Reference in New Issue
Block a user