WMS_MAIN/database/migrations/20260929110000-seed-api-app-list-callback-functions-permission.js

41 lines
1.5 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';
/**
* apiApp.listCallbackFunctions(出站回调 method 注册表拉取)API 权限记录迁移。
*
* 权限明细(固定 ID 636,当前迁移内最大已用 ID=635):
* 636 — apiApp.listCallbackFunctions API:出站回调方法注册表
*
* 角色授权:与同组 apiApp 权限(465-470)口径一致——该组权限仅对
* permissions='*' 的通配角色(超管/经理/仓库管理员)开放,
* 无任何非通配角色持有,因此本迁移仅插入权限记录,不做角色注入。
*
* 幂等:INSERT IGNORE 创建权限记录。
*/
const TABLE = 'wms_permission';
const COLUMNS = 'id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status, created_at, update_at';
module.exports = {
// eslint-disable-next-line no-unused-vars
async up(queryInterface, Sequelize) {
const apis = [
[ 636, 'apiApp.listCallbackFunctions', 'API:出站回调方法注册表' ],
];
for (const [ id, path, metaTitle ] of apis) {
await queryInterface.sequelize.query(
`INSERT IGNORE INTO \`${TABLE}\` (${COLUMNS}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())`,
{ replacements: [ id, path, null, path, null, metaTitle, null, 0, 0, null, 'api', 0, 1 ] }
);
}
},
// eslint-disable-next-line no-unused-vars
async down(queryInterface, Sequelize) {
await queryInterface.sequelize.query(
`DELETE FROM \`${TABLE}\` WHERE id = 636 AND path = 'apiApp.listCallbackFunctions'`
);
},
};