'use strict'; /** * 店铺表扩展:外部打单平台店铺的「来源」。 * * 同一个打单账号下可能有两种来源的店铺: * - agent:平台侧的商家/合作方(如店管家的「绑定商家」LoadMyAgentList),订单按商家归属过滤 * - my_shop:账号自己绑定的平台店铺(如店管家的「我的店铺」LoadMyShopList),订单按店铺ID过滤 * * 该字段由各平台实现自行解释(取值来自 PrintPlatformService.listShopSources()), * 通用层只当作字符串使用,用于区分同一账号下两类店铺的编码、归属与同步口径。 * 老数据(都是商家来源)统一回填为 agent,行为不变。 */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.addColumn('shops', 'external_source', { type: Sequelize.STRING(20), allowNull: false, defaultValue: 'agent', comment: '外部打单平台店铺来源(平台自定义,如 agent/my_shop)', }); await queryInterface.addIndex('shops', { fields: [ 'external_print_account_id', 'external_source' ], name: 'idx_shops_external_account_source', }); }, async down(queryInterface) { await queryInterface.removeIndex('shops', 'idx_shops_external_account_source'); await queryInterface.removeColumn('shops', 'external_source'); }, };