'use strict'; /** * 店铺表扩展:支持从外部打单平台(如店管家的商家)创建店铺。 * * - type:店铺类型(1 平台店铺 / 2 外部打单平台商家),用于区分手工/平台店铺与外部导入店铺 * - external_print_account_id:来源外部打单账号(type=2 时有值),便于按账号查看/追溯 * - external_data:外部打单平台返回的商家原始结构(原样保存,后续按需取字段) * - db_mode:数据库模式(预留字段,供后续分区/多库逻辑使用) */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.addColumn('shops', 'type', { type: Sequelize.TINYINT, allowNull: false, defaultValue: 1, comment: '店铺类型:1平台店铺 2外部打单平台商家', }); await queryInterface.addColumn('shops', 'external_print_account_id', { type: Sequelize.BIGINT.UNSIGNED, allowNull: true, comment: '来源外部打单账号ID(type=2 时有值)', }); await queryInterface.addColumn('shops', 'external_data', { type: Sequelize.JSON, allowNull: true, comment: '外部打单平台返回的商家原始结构', }); await queryInterface.addColumn('shops', 'db_mode', { type: Sequelize.STRING(50), allowNull: true, comment: '数据库模式(预留,后续分区/多库逻辑使用)', }); await queryInterface.addIndex('shops', { fields: [ 'external_print_account_id' ], name: 'idx_shops_external_account' }); await queryInterface.addIndex('shops', { fields: [ 'type' ], name: 'idx_shops_type' }); }, async down(queryInterface) { await queryInterface.removeIndex('shops', 'idx_shops_external_account'); await queryInterface.removeIndex('shops', 'idx_shops_type'); await queryInterface.removeColumn('shops', 'db_mode'); await queryInterface.removeColumn('shops', 'external_data'); await queryInterface.removeColumn('shops', 'external_print_account_id'); await queryInterface.removeColumn('shops', 'type'); }, };