'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'); }, };