'use strict'; /** * 给 wms_after_sale_reply 补两列(开发库补丁,生产幂等跳过)。 * * 背景:20260916190000 建表迁移在开发库执行后补充了两个字段设计—— * - is_reply:是否回复(1=命中后回复,0=静默不回复) * - no_number_hint:未取到单据号时的引导语 * 原迁移文件已同步更新,生产执行时会直接带两列,本迁移在生产幂等跳过。 */ const TABLE = 'wms_after_sale_reply'; module.exports = { up: async (queryInterface, Sequelize) => { const tables = await queryInterface.showAllTables(); const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE); if (!exists) return; const columns = await queryInterface.describeTable(TABLE); if (!columns.is_reply) { await queryInterface.addColumn(TABLE, 'is_reply', { type: Sequelize.TINYINT(1), allowNull: false, defaultValue: 1, comment: '是否回复:1=命中后回复,0=静默不回复', after: 'reply', }); } if (!columns.no_number_hint) { await queryInterface.addColumn(TABLE, 'no_number_hint', { type: Sequelize.STRING(500), allowNull: true, defaultValue: null, comment: '未取到单据号时的引导语(如:请提供运单号;为空则用默认引导语)', after: 'is_reply', }); } }, down: async queryInterface => { const tables = await queryInterface.showAllTables(); const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE); if (!exists) return; const columns = await queryInterface.describeTable(TABLE); if (columns.no_number_hint) { await queryInterface.removeColumn(TABLE, 'no_number_hint'); } if (columns.is_reply) { await queryInterface.removeColumn(TABLE, 'is_reply'); } }, };