feat(部署): 新增 deployment/ 内外网两套按侧部署包
按 demo/ 的写法把交付包改成「角色由目录决定」:iw/ 拷内网机、ow/ 拷外网机, 各自含镜像 tar、SQL、配置与 install.sh,install.sh 不再收 iw/ow 参数。 前端不再打进镜像,改为静态包放在 <侧>/web/ 只读挂进 nginx:1.27-alpine, 现场临时改页面直接替换文件 + restart web 即可。数据仍全部挂宿主机, 子目录命名与 deploy/offline 一致(pgdata/redis/mq/upload/logs/gate), 默认根改为包内 ./volumes,放数据盘只改 .env 的 SFILE_DATA_ROOT。 后端镜像 sfile-app:1.0.1 含传输优化那一批(实测组包 11.4×、解包 9.9×)。 出包脚本 deployment/scripts/build-package.sh 负责 jar→镜像→前端双包→sql→tar→VERSION。
This commit is contained in:
2083
deployment/iw/sql/01-init-table.sql
Normal file
2083
deployment/iw/sql/01-init-table.sql
Normal file
File diff suppressed because it is too large
Load Diff
46
deployment/iw/sql/02-init-data.sql
Normal file
46
deployment/iw/sql/02-init-data.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- 系统uc_platform
|
||||
INSERT INTO uc_platform
|
||||
(platform_code, name, full_name, short_name, business, deleted, create_time)
|
||||
VALUES(1, '文档系统', 's-file', 'file', true, FALSE, now());
|
||||
|
||||
-- 平台机构/平台机构管理员
|
||||
INSERT INTO xs_org
|
||||
(org_name, org_code, type, address_code, address_name, description, quality, enable, activated, parent_id, credit_code, trade, deleted, create_by, create_time, update_by, update_time, proxy_by, activation_code, phone, query_children, org_logo, registered_address, company_size, business_license, recruit_position_type)
|
||||
VALUES('senmesh', 'O001', '1', '440232', NULL, NULL, false, TRUE, TRUE, NULL, '', NULL, FALSE, 0, now(), 1, now(), null, NULL, null, NULL, null, '1234', '6', null, '1');
|
||||
|
||||
INSERT INTO uc_user
|
||||
(username, password, type, supeiror, security_code, nickname, avatar, phone, phone_binding, real_name, card_no, authenticated, status, email, address, education, init_user_id, enabled, account_non_expired, account_non_locked, credentials_non_expired, deleted, create_by, create_time, update_by, update_time, proxy_by, gender, birthday)
|
||||
VALUES('admin', '$2a$10$0N3iaxx2sYv0hXvYzS4.6.yriL.DfjRTjED7Y4vkqxzbxi2dNpBou', 1, TRUE, '$2a$10$mGA1jdBzq8micEr02KiJ9OiYQz1fc/PSVG0hN0EYUuxhZp8EI1M2q', '平台管理员', '', '13888888888', TRUE, '平台管理员', NULL, FALSE, 2, null, NULL, NULL, NULL, TRUE, TRUE, TRUE, TRUE, FALSE, 0, now(), 1, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO uc_org_user
|
||||
(user_id, org_id, administrator, deleted, create_by, create_time, update_by, update_time, proxy_by)
|
||||
VALUES(1, 1, TRUE, FALSE, 0, now(), NULL, NULL, NULL);
|
||||
-- 平台uc_org_relation
|
||||
INSERT INTO uc_org_relation
|
||||
(org_id, org_type, parent_id, path, platform_code, platform_name, deleted, create_by, create_time, update_by, update_time, proxy_by)
|
||||
VALUES(1, 1, 0, '1', 1, NULL, FALSE, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of x_file_category
|
||||
-- ----------------------------
|
||||
INSERT INTO x_file_category (file_category, file_suffix, deleted, create_by, create_time) VALUES
|
||||
('video', 'mp4', FALSE, 0, NOW()),
|
||||
('video', 'mkv', FALSE, 0, NOW()),
|
||||
('video', 'avi', FALSE, 0, NOW()),
|
||||
('video', 'mov', FALSE, 0, NOW()),
|
||||
('video', 'wmv', FALSE, 0, NOW()),
|
||||
('video', 'flv', FALSE, 0, NOW()),
|
||||
('audio', 'mp3', FALSE, 0, NOW()),
|
||||
('audio', 'wav', FALSE, 0, NOW()),
|
||||
('audio', 'flac', FALSE, 0, NOW()),
|
||||
('audio', 'aac', FALSE, 0, NOW()),
|
||||
('document', 'txt', FALSE, 0, NOW()),
|
||||
('document', 'docx', FALSE, 0, NOW()),
|
||||
('document', 'pdf', FALSE, 0, NOW()),
|
||||
('document', 'epub', FALSE, 0, NOW()),
|
||||
('other', 'zip', FALSE, 0, NOW()),
|
||||
('other', 'rar', FALSE, 0, NOW()),
|
||||
('other', '7z', FALSE, 0, NOW()),
|
||||
('other', 'jpg', FALSE, 0, NOW()),
|
||||
('other', 'png', FALSE, 0, NOW()),
|
||||
('other', 'gif', FALSE, 0, NOW()),
|
||||
('other', 'tiff', FALSE, 0, NOW());
|
||||
42
deployment/iw/sql/README.md
Normal file
42
deployment/iw/sql/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
建表与初始数据脚本已随包放好,文件名前缀决定执行顺序(先建表后灌数据):
|
||||
|
||||
| 文件 | 来源 | 说明 |
|
||||
|---|---|---|
|
||||
| `01-init-table.sql` | `backend/db/init-table-postgres-full.sql` | 全量 DDL,含 `x_file_security` 安全检测表与 `idx_file_record_md5_code` 索引 |
|
||||
| `02-init-data.sql` | `backend/db/init-data.sql` | admin 账号、机构、平台编码(`system.code=1` 要与此一致) |
|
||||
|
||||
出包时用 `deployment/scripts/build-package.sh` 从仓库重新覆盖这两份,别手改副本。
|
||||
|
||||
只有 `POSTGRES_*` 指向的库为空时,PostgreSQL 官方镜像才会执行 `docker-entrypoint-initdb.d`;
|
||||
数据目录已有数据时会跳过 —— 想重建就把 `volumes/pgdata` 一起清掉再 `up`。
|
||||
|
||||
## upgrade/ —— 已上线老库的增量脚本(新装不用跑)
|
||||
|
||||
| 文件 | 作用 |
|
||||
|---|---|
|
||||
| `upgrade-20260914-upload-config.sql` | 新增 `x_upload_config`(机构上传后缀白名单/大小上限/开关) |
|
||||
| `upgrade-20260915-release.sql` | 与上一份同一件事(上线汇总版),**两者跑其一即可** |
|
||||
| `upgrade-20261101-meshsafe-file-security.sql` | 新增 `x_file_security` 文件安全检测表与字段 |
|
||||
| `upgrade-20261103-transfer-perf.sql` | 给 `xs_file_record.md5_code` 补索引(解包时按 MD5 去重查询,缺索引就是每文件一次全表扫描) |
|
||||
|
||||
客户如果从 2026-09 之前的老库升上来,本包(PostgreSQL)真正缺的只有三个对象:
|
||||
`x_upload_config`、`x_file_security`、`idx_file_record_md5_code`。
|
||||
这三项在 `01-init-table.sql` 里都已是 PostgreSQL 写法,老库升级建议直接照它补,别整份管道进 psql:
|
||||
|
||||
```bash
|
||||
# 先看缺不缺
|
||||
docker exec -i sfile-iw-pg psql -U sfile -d s_file -c \
|
||||
"\dt x_upload_config" -c "\dt x_file_security" -c "\di idx_file_record_md5_code"
|
||||
|
||||
# 只补 md5 索引(这份脚本带「-- 2. PostgreSQL」分节标题,可以截出来跑)
|
||||
awk '/^-- 2\. PostgreSQL/{f=1} f' sql/upgrade/upgrade-20261103-transfer-perf.sql \
|
||||
| docker exec -i sfile-iw-pg psql -U sfile -d s_file
|
||||
```
|
||||
|
||||
> 注意:这 4 份历史增量脚本是**达梦/MySQL 优先**写的,`upgrade-20260915-release.sql` 的 PostgreSQL 段整段是注释掉的,
|
||||
> 只有 `upgrade-20261101`、`upgrade-20261103` 两份带可执行的「第 2 节 PostgreSQL」。别照着 MySQL 段硬跑。
|
||||
|
||||
这两份带可执行第 2 节的脚本都是「第 1 节 MySQL/达梦、第 2 节 PostgreSQL」双库混排,**只能跑第 2 节**,
|
||||
整份管道进去会先执行 MySQL 那节。它们不会自动执行,要人工触发(容器名内网机 `sfile-iw-pg` / 外网机 `sfile-ow-pg`)。
|
||||
|
||||
数据量大时建索引会锁写,放到业务低峰执行;不能停写就用脚本里注明的 `CONCURRENTLY` 写法。
|
||||
62
deployment/iw/sql/upgrade/upgrade-20260914-upload-config.sql
Normal file
62
deployment/iw/sql/upgrade/upgrade-20260914-upload-config.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
-- =============================================================
|
||||
-- 升级脚本:机构上传配置(文件上传类型/大小限制)
|
||||
-- 日期:2026-09-14
|
||||
-- 说明:新增 x_upload_config 表(一行对应一个机构)。
|
||||
-- 机构管理员可配置本机构允许上传的文件后缀白名单、
|
||||
-- 单文件大小上限、上传总开关;未配置的机构默认允许全部。
|
||||
-- 拦截点:网盘上传落库(normal_user_file/create)。
|
||||
-- 执行方式:MySQL/达梦(DM8 MySQL兼容模式)执行第 1 节;
|
||||
-- PostgreSQL 执行第 2 节。
|
||||
-- =============================================================
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 1. MySQL / 达梦 DM8
|
||||
-- -------------------------------------------------------------
|
||||
CREATE TABLE `x_upload_config` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`org_id` bigint(20) DEFAULT NULL COMMENT '机构id',
|
||||
`upload_enabled` bit(1) DEFAULT b'1' COMMENT '是否允许上传',
|
||||
`allow_all_type` bit(1) DEFAULT b'1' COMMENT '是否允许全部类型(false时按allowed_suffixes白名单校验)',
|
||||
`allowed_suffixes` varchar(1024) DEFAULT NULL COMMENT '允许的文件后缀(逗号分隔,小写),allow_all_type=false时生效',
|
||||
`max_file_size` bigint(20) DEFAULT NULL COMMENT '单文件大小上限(MB),空或0不限制',
|
||||
`deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
|
||||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` bigint(20) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
`proxy_by` bigint(20) DEFAULT NULL COMMENT '代理人',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_org_id` (`org_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='机构上传配置';
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 2. PostgreSQL
|
||||
-- -------------------------------------------------------------
|
||||
CREATE TABLE x_upload_config (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
org_id BIGINT DEFAULT NULL,
|
||||
upload_enabled BOOLEAN DEFAULT TRUE,
|
||||
allow_all_type BOOLEAN DEFAULT TRUE,
|
||||
allowed_suffixes VARCHAR(1024) DEFAULT NULL,
|
||||
max_file_size BIGINT DEFAULT NULL,
|
||||
deleted BOOLEAN DEFAULT FALSE,
|
||||
create_by BIGINT DEFAULT NULL,
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
update_by BIGINT DEFAULT NULL,
|
||||
update_time TIMESTAMP DEFAULT NULL,
|
||||
proxy_by BIGINT DEFAULT NULL,
|
||||
CONSTRAINT uk_upload_config_org_id UNIQUE (org_id)
|
||||
);
|
||||
COMMENT ON TABLE x_upload_config IS '机构上传配置';
|
||||
COMMENT ON COLUMN x_upload_config.id IS '主键ID';
|
||||
COMMENT ON COLUMN x_upload_config.org_id IS '机构id';
|
||||
COMMENT ON COLUMN x_upload_config.upload_enabled IS '是否允许上传';
|
||||
COMMENT ON COLUMN x_upload_config.allow_all_type IS '是否允许全部类型(false时按allowed_suffixes白名单校验)';
|
||||
COMMENT ON COLUMN x_upload_config.allowed_suffixes IS '允许的文件后缀(逗号分隔,小写),allow_all_type=false时生效';
|
||||
COMMENT ON COLUMN x_upload_config.max_file_size IS '单文件大小上限(MB),空或0不限制';
|
||||
COMMENT ON COLUMN x_upload_config.deleted IS '是否删除';
|
||||
COMMENT ON COLUMN x_upload_config.create_by IS '创建人';
|
||||
COMMENT ON COLUMN x_upload_config.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN x_upload_config.update_by IS '修改人';
|
||||
COMMENT ON COLUMN x_upload_config.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN x_upload_config.proxy_by IS '代理人';
|
||||
90
deployment/iw/sql/upgrade/upgrade-20260915-release.sql
Normal file
90
deployment/iw/sql/upgrade/upgrade-20260915-release.sql
Normal file
@@ -0,0 +1,90 @@
|
||||
-- =====================================================================
|
||||
-- s-file 上线数据库脚本(2026-09-15 版本)
|
||||
-- 适用场景:已有生产库升级(老版本 → 当前版本)
|
||||
--
|
||||
-- 本次版本(用户启停/注销、机构账号查询、手机号查记录、机构上传配置)
|
||||
-- 相对老版本的数据库变更只有一项:
|
||||
-- 新增表 x_upload_config(机构上传配置)
|
||||
-- 其余功能(启停/注销/查询)全部复用已有表字段,无需任何变更。
|
||||
--
|
||||
-- 【执行说明】
|
||||
-- * 生产主力库为达梦 DM8(MySQL 兼容模式)→ 只执行【第一部分】
|
||||
-- * 若目标库是 PostgreSQL → 只执行【第二部分】
|
||||
-- * 执行前建议备份;执行后核对【第三部分】的验证 SQL
|
||||
-- * 可重复执行(幂等):表已存在时再执行会报"已存在"错误,属正常,
|
||||
-- 说明该脚本已执行过,无需处理
|
||||
-- =====================================================================
|
||||
|
||||
|
||||
-- =====================================================================
|
||||
-- 第一部分:达梦 DM8 / MySQL
|
||||
-- =====================================================================
|
||||
|
||||
CREATE TABLE x_upload_config (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
org_id BIGINT DEFAULT NULL COMMENT '机构id',
|
||||
upload_enabled BIT(1) DEFAULT b'1' COMMENT '是否允许上传',
|
||||
allow_all_type BIT(1) DEFAULT b'1' COMMENT '是否允许全部类型(false时按allowed_suffixes白名单校验)',
|
||||
allowed_suffixes VARCHAR(1024) DEFAULT NULL COMMENT '允许的文件后缀(逗号分隔,小写),allow_all_type=false时生效',
|
||||
max_file_size BIGINT DEFAULT NULL COMMENT '单文件大小上限(MB),空或0不限制',
|
||||
deleted BIT(1) DEFAULT b'0' COMMENT '是否删除',
|
||||
create_by BIGINT DEFAULT NULL COMMENT '创建人',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_by BIGINT DEFAULT NULL COMMENT '修改人',
|
||||
update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
proxy_by BIGINT DEFAULT NULL COMMENT '代理人',
|
||||
PRIMARY KEY (id) USING BTREE,
|
||||
UNIQUE KEY uk_org_id (org_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='机构上传配置';
|
||||
|
||||
-- 说明:不需要初始化数据。
|
||||
-- 未配置的机构 = 默认策略(允许上传全部类型、不限大小),
|
||||
-- 由各机构管理员在管理后台"上传配置"页面自行配置后落库。
|
||||
|
||||
|
||||
-- =====================================================================
|
||||
-- 第二部分:PostgreSQL
|
||||
-- =====================================================================
|
||||
|
||||
-- CREATE TABLE x_upload_config (
|
||||
-- id BIGSERIAL PRIMARY KEY,
|
||||
-- org_id BIGINT DEFAULT NULL,
|
||||
-- upload_enabled BOOLEAN DEFAULT TRUE,
|
||||
-- allow_all_type BOOLEAN DEFAULT TRUE,
|
||||
-- allowed_suffixes VARCHAR(1024) DEFAULT NULL,
|
||||
-- max_file_size BIGINT DEFAULT NULL,
|
||||
-- deleted BOOLEAN DEFAULT FALSE,
|
||||
-- create_by BIGINT DEFAULT NULL,
|
||||
-- create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
-- update_by BIGINT DEFAULT NULL,
|
||||
-- update_time TIMESTAMP DEFAULT NULL,
|
||||
-- proxy_by BIGINT DEFAULT NULL,
|
||||
-- CONSTRAINT uk_upload_config_org_id UNIQUE (org_id)
|
||||
-- );
|
||||
-- COMMENT ON TABLE x_upload_config IS '机构上传配置';
|
||||
-- COMMENT ON COLUMN x_upload_config.id IS '主键ID';
|
||||
-- COMMENT ON COLUMN x_upload_config.org_id IS '机构id';
|
||||
-- COMMENT ON COLUMN x_upload_config.upload_enabled IS '是否允许上传';
|
||||
-- COMMENT ON COLUMN x_upload_config.allow_all_type IS '是否允许全部类型(false时按allowed_suffixes白名单校验)';
|
||||
-- COMMENT ON COLUMN x_upload_config.allowed_suffixes IS '允许的文件后缀(逗号分隔,小写),allow_all_type=false时生效';
|
||||
-- COMMENT ON COLUMN x_upload_config.max_file_size IS '单文件大小上限(MB),空或0不限制';
|
||||
-- COMMENT ON COLUMN x_upload_config.deleted IS '是否删除';
|
||||
-- COMMENT ON COLUMN x_upload_config.create_by IS '创建人';
|
||||
-- COMMENT ON COLUMN x_upload_config.create_time IS '创建时间';
|
||||
-- COMMENT ON COLUMN x_upload_config.update_by IS '修改人';
|
||||
-- COMMENT ON COLUMN x_upload_config.update_time IS '修改时间';
|
||||
-- COMMENT ON COLUMN x_upload_config.proxy_by IS '代理人';
|
||||
|
||||
|
||||
-- =====================================================================
|
||||
-- 第三部分:执行后验证(达梦/MySQL 语法)
|
||||
-- =====================================================================
|
||||
|
||||
-- 1) 表存在且为空(0 行正常)
|
||||
-- SELECT COUNT(*) FROM x_upload_config;
|
||||
|
||||
-- 2) 唯一约束存在(应返回 uk_org_id)
|
||||
-- SELECT INDEX_NAME FROM USER_INDEXES WHERE TABLE_NAME = 'X_UPLOAD_CONFIG';
|
||||
|
||||
-- 3) (可选)回滚脚本 —— 如需回滚上线:
|
||||
-- DROP TABLE x_upload_config;
|
||||
@@ -0,0 +1,71 @@
|
||||
-- =============================================================
|
||||
-- 升级脚本:MeshSafe 文件安全检测对接
|
||||
-- 日期:2026-11-01
|
||||
-- 说明:新增 x_file_security 表(按文件编码维度记录安全检测结果)。
|
||||
-- 文件上传/传输接收解包后自动提交 MeshSafe 检测,
|
||||
-- 检测结论(通过/不通过)回写本表;同一文件允许多条检测
|
||||
-- 记录(人工复核、重新检测均新增记录),业务取最新一条生效。
|
||||
-- 检测不通过的文件禁止分享与跨网传输(下载预览不受限)。
|
||||
-- 执行方式:MySQL/达梦(DM8 MySQL兼容模式)执行第 1 节;
|
||||
-- PostgreSQL 执行第 2 节。
|
||||
-- =============================================================
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 1. MySQL / 达梦 DM8
|
||||
-- -------------------------------------------------------------
|
||||
CREATE TABLE `x_file_security` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`file_code` varchar(32) DEFAULT NULL COMMENT '文件编码',
|
||||
`task_id` varchar(64) DEFAULT NULL COMMENT 'MeshSafe检测任务ID',
|
||||
`scan_status` varchar(2) DEFAULT NULL COMMENT '检测状态:1检测中/2通过/3不通过/4检测失败',
|
||||
`action` varchar(32) DEFAULT NULL COMMENT 'MeshSafe处置动作:pass/manual_review/reject',
|
||||
`reason` varchar(1024) DEFAULT NULL COMMENT '检测结论说明',
|
||||
`result_json` text DEFAULT NULL COMMENT '检测完整结果JSON',
|
||||
`review_comment` varchar(512) DEFAULT NULL COMMENT '人工复核说明(人工改判时有值)',
|
||||
`deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
|
||||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` bigint(20) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
`proxy_by` bigint(20) DEFAULT NULL COMMENT '代理人',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_file_security_file_code` (`file_code`) USING BTREE,
|
||||
KEY `idx_file_security_scan_status` (`scan_status`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件安全检测记录';
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 2. PostgreSQL
|
||||
-- -------------------------------------------------------------
|
||||
CREATE TABLE x_file_security (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
file_code VARCHAR(32) DEFAULT NULL,
|
||||
task_id VARCHAR(64) DEFAULT NULL,
|
||||
scan_status VARCHAR(2) DEFAULT NULL,
|
||||
action VARCHAR(32) DEFAULT NULL,
|
||||
reason VARCHAR(1024) DEFAULT NULL,
|
||||
result_json TEXT DEFAULT NULL,
|
||||
review_comment VARCHAR(512) DEFAULT NULL,
|
||||
deleted BOOLEAN DEFAULT FALSE,
|
||||
create_by BIGINT DEFAULT NULL,
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
update_by BIGINT DEFAULT NULL,
|
||||
update_time TIMESTAMP DEFAULT NULL,
|
||||
proxy_by BIGINT DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX idx_file_security_file_code ON x_file_security(file_code);
|
||||
CREATE INDEX idx_file_security_scan_status ON x_file_security(scan_status);
|
||||
COMMENT ON TABLE x_file_security IS '文件安全检测记录';
|
||||
COMMENT ON COLUMN x_file_security.id IS '主键ID';
|
||||
COMMENT ON COLUMN x_file_security.file_code IS '文件编码';
|
||||
COMMENT ON COLUMN x_file_security.task_id IS 'MeshSafe检测任务ID';
|
||||
COMMENT ON COLUMN x_file_security.scan_status IS '检测状态:1检测中/2通过/3不通过/4检测失败';
|
||||
COMMENT ON COLUMN x_file_security.action IS 'MeshSafe处置动作:pass/manual_review/reject';
|
||||
COMMENT ON COLUMN x_file_security.reason IS '检测结论说明';
|
||||
COMMENT ON COLUMN x_file_security.result_json IS '检测完整结果JSON';
|
||||
COMMENT ON COLUMN x_file_security.review_comment IS '人工复核说明(人工改判时有值)';
|
||||
COMMENT ON COLUMN x_file_security.deleted IS '是否删除';
|
||||
COMMENT ON COLUMN x_file_security.create_by IS '创建人';
|
||||
COMMENT ON COLUMN x_file_security.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN x_file_security.update_by IS '修改人';
|
||||
COMMENT ON COLUMN x_file_security.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN x_file_security.proxy_by IS '代理人';
|
||||
26
deployment/iw/sql/upgrade/upgrade-20261103-transfer-perf.sql
Normal file
26
deployment/iw/sql/upgrade/upgrade-20261103-transfer-perf.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- =============================================================
|
||||
-- 升级脚本:跨网传输链路性能优化(第一批)
|
||||
-- 日期:2026-11-03
|
||||
-- 说明:给 xs_file_record.md5_code 补索引。
|
||||
-- 文件入库时会用 MD5 做内容去重查询
|
||||
-- (FileServiceImpl 上传 → find(md5Code)),此前该列无索引,
|
||||
-- 每个文件入库都是一次全表扫描。解包一个含 N 个文件的传输包
|
||||
-- 就是 N 次全表扫描,数据量上来后是多文件解包的主要数据库开销。
|
||||
-- 新环境由 init 脚本建表时已包含该索引,本脚本仅供已上线环境增量执行。
|
||||
-- 执行方式:MySQL/达梦(DM8 MySQL兼容模式)执行第 1 节;
|
||||
-- PostgreSQL 执行第 2 节。
|
||||
-- 注意:表数据量大时建索引会锁写,建议业务低峰执行。
|
||||
-- 重复执行会报「索引已存在」,忽略即可。
|
||||
-- =============================================================
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 1. MySQL / 达梦 DM8
|
||||
-- -------------------------------------------------------------
|
||||
CREATE INDEX idx_file_record_md5_code ON xs_file_record(md5_code);
|
||||
|
||||
-- -------------------------------------------------------------
|
||||
-- 2. PostgreSQL
|
||||
-- -------------------------------------------------------------
|
||||
-- 表已有数据且不能停写时,改用下面这句(不可在事务块内执行):
|
||||
-- CREATE INDEX CONCURRENTLY idx_file_record_md5_code ON xs_file_record(md5_code);
|
||||
CREATE INDEX IF NOT EXISTS idx_file_record_md5_code ON xs_file_record(md5_code);
|
||||
Reference in New Issue
Block a user