Hotfix migrations

This commit is contained in:
Stefan Zermatten
2023-06-22 15:52:42 +02:00
parent 70edd7b2c0
commit bae621cd47
2 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import CreatureProperties from '/imports/api/creature/creatureProperties/Creatur
import applyFnToKey from '/imports/api/engine/computation/utility/applyFnToKey.js';
import { get } from 'lodash';
const dollarSignRegex = /(\W)\$(\w+)/gi;
const dollarSignRegex = /(\W|^)\$(\w+)/gi;
export default function migrate1To2(archive) {
archive.properties = archive.properties.map(prop => {

View File

@@ -70,10 +70,10 @@ export function migratePropUp(prop, collection) {
// Replace dollar sign with tilde in calculated fields
update = dollarSignToTilde(prop, update);
// update the document, respecting the schema
// update the document
if (update) {
try {
collection.update({ _id: prop._id }, update, { selector: { type: prop.type } });
collection.update({ _id: prop._id }, update, { bypassCollection2: true });
} catch (e) {
console.warn('Doc Migration failed: ', prop._id, e);
}
@@ -97,7 +97,7 @@ export function migratePropDown(prop, collection) {
}
if (update) {
try {
collection.update({ _id: prop._id }, update, { selector: { type: prop.type } });
collection.update({ _id: prop._id }, update, { bypassCollection2: true });
} catch (e) {
console.warn('Doc Migration failed: ', prop._id, e);
}
@@ -130,7 +130,7 @@ function countSubscribers() {
bulkLibCols.execute();
}
const dollarSignRegex = /(\W)\$(\w+)/gi;
const dollarSignRegex = /(\W|^)\$(\w+)/gi;
function dollarSignToTilde(prop, update) {
computedSchemas[prop.type]?.inlineCalculationFields()?.forEach(calcKey => {
applyFnToKey(prop, calcKey, (prop, key) => {