63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
// models/UnitMaster.js
|
|
module.exports = (sequelize, DataTypes) => {
|
|
const UnitMaster = sequelize.define(
|
|
"UnitMaster",
|
|
{
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
},
|
|
uom_short_name: {
|
|
type: DataTypes.STRING(20),
|
|
allowNull: false,
|
|
},
|
|
uom: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
},
|
|
is_base_unit: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: false,
|
|
},
|
|
base_unit_id: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
},
|
|
factor: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
},
|
|
description: {
|
|
type: DataTypes.STRING(1000),
|
|
allowNull: false,
|
|
validate: {
|
|
len: {
|
|
args: [1, 1000],
|
|
msg: "Description is too long. Maximum allowed length is 1000 characters."
|
|
}}
|
|
},
|
|
is_active: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: true,
|
|
},
|
|
created_by: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
},
|
|
updated_by: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
},
|
|
},
|
|
{
|
|
tableName: "unit_master",
|
|
timestamps: true,
|
|
createdAt: "created_at",
|
|
updatedAt: "updated_at",
|
|
}
|
|
);
|
|
|
|
return UnitMaster;
|
|
};
|
|
|