'use strict'; /** * 入库单 / 出库单「作废」字段: * - void_at:作废时间 * - void_by:作废人ID(关联 users) * - void_reason:作废原因(选填) * 配合状态值 5=已作废 使用:已审核(2) 及之后的单据禁止物理删除,已审核单只能作废。 */ const TABLES = [ 'inbound_orders', 'outbound_orders' ]; const COLUMNS = [ 'void_at', 'void_by', 'void_reason' ]; module.exports = { async up(queryInterface, Sequelize) { const { DATE, BIGINT, STRING } = Sequelize; for (const table of TABLES) { await queryInterface.addColumn(table, 'void_at', { type: DATE, allowNull: true, comment: '作废时间', }); await queryInterface.addColumn(table, 'void_by', { type: BIGINT.UNSIGNED, allowNull: true, comment: '作废人ID(关联 users)', }); await queryInterface.addColumn(table, 'void_reason', { type: STRING(255), allowNull: true, comment: '作废原因', }); } }, async down(queryInterface) { for (const table of TABLES) { const cols = await queryInterface.describeTable(table); for (const c of COLUMNS) { if (cols[c]) await queryInterface.removeColumn(table, c); } } }, };