- 商品/商品图片、店铺、店铺商品、组合商品及明细 - 仓库、仓库商品(WMS itemId 映射)、仓库接口配置与字段定义(warehouseApi/warehouseApiField) - 库存:stock_items、product_stocks(ZC/CC 双维度)与库存重算工具(utils/recalcStock.js) - 库存单据与对接日志:stock orders、api_outbound_logs - 相关迁移:shops/shop_products/stock_orders/warehouses/warehouse_apis/warehouse_products/product_stocks/files-images 等表与字段
56 lines
2.3 KiB
JavaScript
56 lines
2.3 KiB
JavaScript
'use strict';
|
||
|
||
/** 9. 店铺表:归属于具体主体,一个主体可有多个平台店铺 */
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
await queryInterface.createTable(
|
||
'shops',
|
||
{
|
||
id: {
|
||
type: Sequelize.BIGINT.UNSIGNED,
|
||
allowNull: false,
|
||
autoIncrement: true,
|
||
primaryKey: true,
|
||
},
|
||
principal_id: {
|
||
type: Sequelize.BIGINT.UNSIGNED,
|
||
allowNull: false,
|
||
comment: '所属主体ID',
|
||
references: { model: 'principals', key: 'id' },
|
||
},
|
||
code: { type: Sequelize.STRING(50), allowNull: false, comment: '店铺编码(平台店铺ID或自定义编码)' },
|
||
name: { type: Sequelize.STRING(100), allowNull: false, comment: '店铺名称' },
|
||
platform: { type: Sequelize.STRING(50), allowNull: true, comment: '所属平台:taobao/pdd/douyin/jd/other' },
|
||
contact_name: { type: Sequelize.STRING(50), allowNull: true, comment: '联系人' },
|
||
contact_phone: { type: Sequelize.STRING(20), allowNull: true, comment: '联系电话' },
|
||
status: { type: Sequelize.TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
|
||
extra: { type: Sequelize.JSON, allowNull: true, comment: '扩展配置 JSON:授权信息、接口参数等' },
|
||
remark: { type: Sequelize.STRING(255), allowNull: true, comment: '备注' },
|
||
created_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
},
|
||
updated_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
|
||
},
|
||
},
|
||
{ charset: 'utf8mb4', collate: 'utf8mb4_unicode_ci', comment: '店铺表' }
|
||
);
|
||
|
||
await queryInterface.addIndex('shops', {
|
||
fields: [ 'principal_id', 'code' ],
|
||
unique: true,
|
||
name: 'uk_shops_principal_code',
|
||
});
|
||
await queryInterface.addIndex('shops', { fields: [ 'principal_id' ], name: 'idx_shops_principal' });
|
||
await queryInterface.addIndex('shops', { fields: [ 'platform' ], name: 'idx_shops_platform' });
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
await queryInterface.dropTable('shops');
|
||
},
|
||
};
|