'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { const { STRING, BIGINT } = Sequelize; const tableName = 'wms_after_sale'; // 检查列是否存在 const [columns] = await queryInterface.sequelize.query( `SHOW COLUMNS FROM \`${tableName}\` LIKE 'order_delivery_id'` ); if (Array.isArray(columns) && columns.length > 0) { await queryInterface.removeColumn(tableName, 'order_delivery_id'); } const [columns2] = await queryInterface.sequelize.query( `SHOW COLUMNS FROM \`${tableName}\` LIKE 'order_delivery_no'` ); if (Array.isArray(columns2) && columns2.length > 0) { await queryInterface.removeColumn(tableName, 'order_delivery_no'); } }, down: async (queryInterface, Sequelize) => { const { STRING, BIGINT } = Sequelize; const tableName = 'wms_after_sale'; await queryInterface.addColumn(tableName, 'order_delivery_id', { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '发货订单ID(关联 wms_order_delivery.id)', }); await queryInterface.addColumn(tableName, 'order_delivery_no', { type: STRING(50), allowNull: true, comment: '发货订单号(冗余字段)', }); }, };