// app/model/stock_unit.js 'use strict'; module.exports = app => { const { BIGINT, STRING, INTEGER, DATE } = app.Sequelize; const StockUnit = app.model.define('wms_stock_unit', { id: { type: INTEGER, primaryKey: true, autoIncrement: true, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: true, defaultValue: null, comment: '仓库ID,NULL表示系统默认', }, name: { type: STRING(50), allowNull: false, comment: '单位名称', }, created_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, }, { tableName: 'wms_stock_unit', timestamps: false, comment: '库存单位表', indexes: [ { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ], }, { name: 'uk_name_warehouse', unique: true, fields: [ 'name', 'warehouse_id' ], }, ], }); return StockUnit; };