'use strict'; /** * 修复 wms_order_items 分表的 id 列缺少 AUTO_INCREMENT 的问题。 * * 背景:sync({ alter: true }) 修了所有字段但没有检测到 id 缺少 AUTO_INCREMENT, * 需要手动为以下分表补充: * - wms_order_items_100000_dispatch * - wms_order_items_100000_history * - wms_order_items_1000028 * * @param {import('sequelize').QueryInterface} queryInterface * @param {import('sequelize')} Sequelize * @return {Promise} */ module.exports.up = async (queryInterface, Sequelize) => { const tables = [ 'wms_order_items_100000_dispatch', 'wms_order_items_100000_history', 'wms_order_items_1000028', ]; for (const table of tables) { await queryInterface.sequelize.query( `ALTER TABLE \`${table}\` MODIFY id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT` ); } }; /** * 回滚:移除 AUTO_INCREMENT(恢复为普通 BIGINT UNSIGNED NOT NULL)。 * * @param {import('sequelize').QueryInterface} queryInterface * @param {import('sequelize')} Sequelize * @return {Promise} */ module.exports.down = async (queryInterface, Sequelize) => { const tables = [ 'wms_order_items_100000_dispatch', 'wms_order_items_100000_history', 'wms_order_items_1000028', ]; for (const table of tables) { await queryInterface.sequelize.query( `ALTER TABLE \`${table}\` MODIFY id BIGINT UNSIGNED NOT NULL` ); } };