Files
flask_rulebase_serve/20251118_update.sql
2026-04-22 13:35:40 +08:00

43 lines
1.6 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.

-- 1. 取消 file_path 的唯一约束,保留列
ALTER TABLE bag_file DROP INDEX `file_path`;
-- 2. 为 file_name 建索引(用于 join / like 查询)
ALTER TABLE bag_file
ADD INDEX `idx_bag_file_name` (`file_name`);
-- 3. 为 bag_update_time 建索引(用于 “每个 logical_name 取最新一条” 的子查询)
ALTER TABLE bag_file
ADD INDEX `idx_bag_update_time` (`bag_update_time`);
ALTER TABLE bag_file
ADD INDEX `idx_create_time` (`create_time`);
-- 4. 为 bag_status 建索引
ALTER TABLE bag_file
ADD INDEX idx_bag_status (bag_status);
-- ============================
-- Table structure for bag_merge_record
-- ============================
create table bag_merge_record
(
id int(11) unsigned auto_increment comment '主键'
primary key,
joined_name varchar(255) not null comment '合并后 bag 名称joined_name',
src_name varchar(255) not null comment '参与合并的原始 bag 名称',
create_time datetime default CURRENT_TIMESTAMP not null comment '记录创建时间',
created_by int null comment '操作用户 id',
is_initiator tinyint(1) default 0 not null comment '1: 此 src 是本次合并的主 bag',
constraint fk_bag_merge_created_by
foreign key (created_by) references users (id)
on update cascade on delete set null
)
row_format = DYNAMIC;
create index idx_created_by
on bag_merge_record (created_by);
create index idx_joined_name
on bag_merge_record (joined_name);
create index idx_src_name
on bag_merge_record (src_name);