'use strict'; /** * 商品增加「订单唯一赠品」标记。 * * 置 1 后:订单明细解析到该商品时,**整单只保留一行、数量固定 1**, * 不管平台明细带了多少数量、通过几个组合/几条明细命中(见 lib/orderItemExpand.collapseUniqueGiftRows)。 */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.addColumn('products', 'is_order_unique_gift', { type: Sequelize.TINYINT, allowNull: false, defaultValue: 0, comment: '是否订单唯一赠品:1 是(整单只落一行、数量 1)0 否', after: 'is_batch_mgmt', }); await queryInterface.addIndex('products', [ 'principal_id', 'is_order_unique_gift' ], { name: 'idx_products_principal_unique_gift', }); }, async down(queryInterface) { await queryInterface.removeIndex('products', 'idx_products_principal_unique_gift'); await queryInterface.removeColumn('products', 'is_order_unique_gift'); }, };