102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
'use strict';
|
||
|
||
const TABLE_NAME = 'wms_inbound_direct_log';
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE_NAME);
|
||
if (exists) return;
|
||
|
||
await queryInterface.createTable(TABLE_NAME, {
|
||
id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键ID',
|
||
},
|
||
warehouse_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '仓库ID',
|
||
},
|
||
store_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '货主ID',
|
||
},
|
||
stock_id: {
|
||
type: Sequelize.BIGINT(20),
|
||
allowNull: false,
|
||
comment: '商品SKU ID,关联 wms_stock_warehouse.id',
|
||
},
|
||
quantity: {
|
||
type: Sequelize.INTEGER(12),
|
||
allowNull: false,
|
||
comment: '入库数量',
|
||
},
|
||
inbound_type: {
|
||
type: Sequelize.ENUM('import', 'pda'),
|
||
allowNull: false,
|
||
comment: '入库方式:import-导入入库 pda-PDA入库',
|
||
},
|
||
entry_order_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '关联入库单ID(可选),关联 wms_entry_order.id',
|
||
},
|
||
entry_order_code: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: true,
|
||
comment: '入库单号(冗余,方便查询)',
|
||
},
|
||
remark: {
|
||
type: Sequelize.STRING(500),
|
||
allowNull: true,
|
||
comment: '备注(如导入文件名、PDA操作备注等)',
|
||
},
|
||
operator_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '操作人ID',
|
||
},
|
||
operator_name: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: true,
|
||
comment: '操作人名称',
|
||
},
|
||
created_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
|
||
comment: '创建时间',
|
||
},
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], {
|
||
name: 'idx_warehouse_id',
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'stock_id' ], {
|
||
name: 'idx_stock_id',
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'inbound_type' ], {
|
||
name: 'idx_inbound_type',
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'entry_order_id' ], {
|
||
name: 'idx_entry_order_id',
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'created_at' ], {
|
||
name: 'idx_created_at',
|
||
});
|
||
},
|
||
|
||
down: async queryInterface => {
|
||
await queryInterface.dropTable(TABLE_NAME);
|
||
},
|
||
};
|