'use strict'; /** * 回填存量出入库明细的「应」数量:应入/应出 = 明细数量(quantity)。 * 新字段建列时默认 0,存量数据需与「应=明细数量」规则对齐;「已」数量保持 0(等外部回推)。 */ module.exports = { async up(queryInterface) { await queryInterface.sequelize.query( 'UPDATE stock_items SET plan_in_qty = quantity WHERE bill_type = 1 AND plan_in_qty = 0', ); await queryInterface.sequelize.query( 'UPDATE stock_items SET plan_out_qty = quantity WHERE bill_type = 2 AND plan_out_qty = 0', ); }, async down() { // 回填动作无需回退(列本身由上一个迁移负责增删) }, };