Refactor product model by removing unused sellCostMinNeutral and sellCostMaxNeutral fields, and simplify product insertion logic in initialization script.
This commit is contained in:
@@ -16,17 +16,6 @@ ProductType.init({
|
|||||||
sellCost: {
|
sellCost: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
allowNull: false}
|
allowNull: false}
|
||||||
,
|
|
||||||
sellCostMinNeutral: {
|
|
||||||
type: DataTypes.DECIMAL,
|
|
||||||
allowNull: true,
|
|
||||||
field: 'sell_cost_min_neutral'
|
|
||||||
},
|
|
||||||
sellCostMaxNeutral: {
|
|
||||||
type: DataTypes.DECIMAL,
|
|
||||||
allowNull: true,
|
|
||||||
field: 'sell_cost_max_neutral'
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
sequelize,
|
sequelize,
|
||||||
modelName: 'ProductType',
|
modelName: 'ProductType',
|
||||||
|
|||||||
@@ -282,11 +282,7 @@ async function initializeFalukantProducts() {
|
|||||||
{ labelTr: 'ox', category: 5, productionTime: 5, sellCost: 60 },
|
{ labelTr: 'ox', category: 5, productionTime: 5, sellCost: 60 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const productsToInsert = baseProducts.map(p => ({
|
const productsToInsert = baseProducts;
|
||||||
...p,
|
|
||||||
sellCostMinNeutral: Math.ceil(p.sellCost * factorMin),
|
|
||||||
sellCostMaxNeutral: Math.ceil(p.sellCost * factorMax),
|
|
||||||
}));
|
|
||||||
|
|
||||||
await ProductType.bulkCreate(productsToInsert, {
|
await ProductType.bulkCreate(productsToInsert, {
|
||||||
ignoreDuplicates: true,
|
ignoreDuplicates: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user