oms/backend/database/migrations/20260909001100-remove-menu-management.js
liufumingren 8597cf5ac9 feat(backend): 用户鉴权、菜单权限、主体与系统基础模块
- 登录/邮箱验证码/密码流程(controller/auth.js、lib/emailCode.js、middleware/jwt_auth.js)
- 主体(principal)隔离与主体用户、对外接口配置模块及 principalCheck 中间件
- 菜单、用户、文件上传、快递公司字典(express_companies)等基础模块
- 通用工具:分页(lib/pagination.js)、缓存(service/cache.js)
- 全量接口契约(contract/index.js)与路由注册(router.js)、config.default.js 配置
- 相关迁移:菜单组件调整与菜单种子、创建 files 表
2026-09-13 02:23:34 +08:00

43 lines
1.3 KiB
JavaScript
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.

'use strict';
/**
* 移除侧边栏「系统管理 → 菜单管理」菜单项。
* 注意:仅删除菜单记录,后端 /api/menus 接口(尤其 /api/menus/tree)必须保留,
* 它是前端动态菜单与路由的数据来源。
*/
module.exports = {
async up(queryInterface) {
await queryInterface.sequelize.query(
`DELETE FROM menus WHERE name = ? AND path = ? AND type = 2`,
{ replacements: ['菜单管理', '/system/menu'] },
);
},
async down(queryInterface) {
const sequelize = queryInterface.sequelize;
// 回滚时重新挂回「系统管理」目录下
const [parent] = await sequelize.query(
`SELECT id FROM menus WHERE name = ? AND parent_id = 0 AND type = 1 LIMIT 1`,
{ replacements: ['系统管理'], type: sequelize.QueryTypes.SELECT },
);
if (!parent) return;
await sequelize.query(
`INSERT INTO menus
(parent_id, name, type, path, icon, permission, component, sort, status, created_at, updated_at)
VALUES (?, ?, 2, ?, ?, ?, ?, ?, 1, NOW(), NOW())`,
{
replacements: [
parent.id,
'菜单管理',
'/system/menu',
'Menu',
'menu:list',
'views/Generic.vue',
60,
],
},
);
},
};