oms/backend/database/migrations/20260910000000-add-created-by-to-stock-orders.js
liufumingren cbd16752a5 feat(backend): 商品、店铺、组合商品、仓库与库存模块
- 商品/商品图片、店铺、店铺商品、组合商品及明细
- 仓库、仓库商品(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 等表与字段
2026-09-13 02:23:39 +08:00

31 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 为入库单 / 出库单增加"创建人"字段,记录单据创建者的用户ID
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('inbound_orders', 'created_by', {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
comment: '创建人ID(关联 users)',
references: { model: 'users', key: 'id' },
onDelete: 'SET NULL',
});
await queryInterface.addColumn('outbound_orders', 'created_by', {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
comment: '创建人ID(关联 users)',
references: { model: 'users', key: 'id' },
onDelete: 'SET NULL',
});
await queryInterface.addIndex('inbound_orders', { fields: ['created_by'], name: 'idx_inbound_orders_created_by' });
await queryInterface.addIndex('outbound_orders', { fields: ['created_by'], name: 'idx_outbound_orders_created_by' });
},
async down(queryInterface) {
await queryInterface.removeColumn('inbound_orders', 'created_by');
await queryInterface.removeColumn('outbound_orders', 'created_by');
},
};