'use strict'; /** * 创建容器(篮筐)资产登记表 wms_container。 * * 用于登记仓库的物理容器(篮筐)资产:容器编号、使用状态、是否损坏、损坏说明、备注等。 * 同一仓库内容器编号唯一(uk_warehouse_container_no),通过 warehouse_id 做数据隔离。 * * 后续用途:散单拣货把购物车商品临时转移到容器时,通过 status 标记容器占用/空闲。 * * 字段: * warehouse_id 仓库ID(数据隔离维度) * container_no 容器编号(篮筐编号) * status 使用状态(idle=空闲 in_use=占用) * is_damaged 是否损坏(Y=损坏 N=正常) * damage_remark 损坏说明 * remark 备注 * creator_id / creator_name 登记人 * created_at / updated_at 审计时间 * * 索引: * uk_warehouse_container_no(warehouse_id + container_no 唯一) * idx_warehouse_id * idx_status * idx_is_damaged */ const TABLE_NAME = 'wms_container'; module.exports = { // eslint-disable-next-line no-unused-vars async up(queryInterface, Sequelize) { const { BIGINT, STRING, ENUM, DATE } = Sequelize; await queryInterface.createTable(TABLE_NAME, { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID(数据隔离维度)', }, container_no: { type: STRING(50), allowNull: false, comment: '容器编号(篮筐编号)', }, status: { type: ENUM('idle', 'in_use'), allowNull: false, defaultValue: 'idle', comment: '使用状态:idle=空闲 in_use=占用(散单商品临时转移)', }, is_damaged: { type: ENUM('Y', 'N'), allowNull: false, defaultValue: 'N', comment: '是否损坏:Y=损坏 N=正常', }, damage_remark: { type: STRING(255), allowNull: true, comment: '损坏说明', }, remark: { type: STRING(500), allowNull: true, comment: '备注', }, creator_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '登记人账户ID', }, creator_name: { type: STRING(50), allowNull: true, comment: '登记人名称快照', }, created_at: { type: DATE, allowNull: false, comment: '创建时间' }, updated_at: { type: DATE, allowNull: false, comment: '更新时间' }, }); await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'container_no' ], { unique: true, name: 'uk_warehouse_container_no' }); await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' }); await queryInterface.addIndex(TABLE_NAME, [ 'status' ], { name: 'idx_status' }); await queryInterface.addIndex(TABLE_NAME, [ 'is_damaged' ], { name: 'idx_is_damaged' }); }, // eslint-disable-next-line no-unused-vars async down(queryInterface, Sequelize) { await queryInterface.dropTable(TABLE_NAME); }, };