'use strict'; module.exports = { async up(queryInterface) { // 给客服及以上角色追加 打包流水(449) 和 复核流水(450) 权限 // 排除 permissions='*' 的角色(已有全部权限) await queryInterface.sequelize.query(` UPDATE wms_role SET permissions = JSON_ARRAY_APPEND(permissions, '$', 449, '$', 450), updated_at = NOW() WHERE id IN (5, 8, 26, 27, 28, 29, 30, 31, 32, 33, 34) AND permissions IS NOT NULL AND permissions != '*' AND permissions != '[]' AND JSON_VALID(permissions) = 1 AND JSON_CONTAINS(permissions, '449', '$') = 0 `); }, async down(queryInterface) { // 回滚:从角色权限中移除 449 和 450 await queryInterface.sequelize.query(` UPDATE wms_role SET permissions = JSON_REMOVE( JSON_REMOVE(permissions, JSON_UNQUOTE(JSON_SEARCH(permissions, 'one', '449'))), JSON_UNQUOTE(JSON_SEARCH(permissions, 'one', '450')) ), updated_at = NOW() WHERE id IN (5, 8, 26, 27, 28, 29, 30, 31, 32, 33, 34) AND permissions IS NOT NULL AND permissions != '*' AND JSON_VALID(permissions) = 1 AND JSON_CONTAINS(permissions, '449', '$') = 1 `); }, };