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

@@ -5,9 +5,8 @@ import {
InlineCalculationFieldSchema,
} from '/imports/api/properties/subSchemas/InlineCalculationFieldSchema.js';
import {
FieldToComputeSchema,
ComputedOnlyFieldSchema,
ComputedFieldSchema,
fieldToCompute,
computedOnlyField,
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
import {
ResourcesSchema,
@@ -60,7 +59,7 @@ let ActionSchema = new SimpleSchema({
},
// Calculation of how many times this action can be used
uses: {
type: FieldToComputeSchema,
type: Object,
optional: true,
},
// Integer of how many times it has already been used
@@ -74,7 +73,7 @@ let ActionSchema = new SimpleSchema({
allowedValues: ['longRest', 'shortRest'],
optional: true,
},
});
}).extend(fieldToCompute('uses'));
const ComputedOnlyActionSchema = new SimpleSchema({
summary: {
@@ -85,10 +84,6 @@ const ComputedOnlyActionSchema = new SimpleSchema({
type: ComputedOnlyInlineCalculationFieldSchema,
optional: true,
},
uses: {
type: ComputedOnlyFieldSchema,
optional: true,
},
resources: {
type: ResourcesComputedOnlySchema,
defaultValue: {},
@@ -99,16 +94,12 @@ const ComputedOnlyActionSchema = new SimpleSchema({
type: Boolean,
optional: true,
},
});
}).extend(computedOnlyField('uses'));
const ComputedActionSchema = new SimpleSchema()
.extend(ActionSchema)
.extend(ComputedOnlyActionSchema)
.extend({
uses: {
type: ComputedFieldSchema,
optional: true,
},
summary: {
type: InlineCalculationFieldSchema,
optional: true,