Improved migration code substantially, wrote migrations for more properties

This commit is contained in:
Stefan Zermatten
2021-09-06 17:40:57 +02:00
parent 235560eb44
commit e79b8fda3b
20 changed files with 525 additions and 303 deletions

View File

@@ -1,15 +1,20 @@
import SimpleSchema from 'simpl-schema';
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import {
fieldToCompute,
computedOnlyField,
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
const AdjustmentSchema = new SimpleSchema({
// The roll that determines how much to change the attribute
// This can be simplified, but should only compute when activated
amount: {
type: String,
type: Object,
optional: true,
defaultValue: '1',
max: STORAGE_LIMITS.calculation,
},
'amount.calculation': {
type: String,
defaultValue: 1,
},
// Who this adjustment applies to
target: {
@@ -32,22 +37,9 @@ const AdjustmentSchema = new SimpleSchema({
allowedValues: ['set', 'increment'],
defaultValue: 'increment',
},
});
}).extend(fieldToCompute('amount'));
const ComputedOnlyAdjustmentSchema = new SimpleSchema({
amountResult: {
type: SimpleSchema.oneOf(String, Number),
optional: true,
},
amountErrors: {
type: Array,
optional: true,
maxCount: STORAGE_LIMITS.errorCount,
},
'amountErrors.$':{
type: ErrorSchema,
},
});
const ComputedOnlyAdjustmentSchema = computedOnlyField('amount');
const ComputedAdjustmentSchema = new SimpleSchema()
.extend(AdjustmentSchema)