'use strict'; /** * 为店铺表新增自定义名称字段。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @param {import('sequelize')} Sequelize Sequelize 实例 * @return {Promise} 无返回值 */ module.exports = { /** * 执行迁移:新增店铺自定义名称字段(幂等)。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @param {import('sequelize')} Sequelize Sequelize 实例 * @return {Promise} 无返回值 */ async up(queryInterface, Sequelize) { const tableName = 'wms_shops'; const columns = await queryInterface.describeTable(tableName); if (!columns.custom_name) { await queryInterface.addColumn(tableName, 'custom_name', { type: Sequelize.STRING(100), allowNull: true, comment: '店铺自定义名称', }); } }, /** * 回滚迁移:删除店铺自定义名称字段(幂等)。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @return {Promise} 无返回值 */ async down(queryInterface) { const tableName = 'wms_shops'; const columns = await queryInterface.describeTable(tableName); if (columns.custom_name) { await queryInterface.removeColumn(tableName, 'custom_name'); } }, };