Skip to content

Commit 9806ed9

Browse files
committed
fix: Ensure CoreSystem.settingsWithOverrides is valid
1 parent 9445b45 commit 9806ed9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

meteor/server/migration/X_X_X.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,66 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
310310
}
311311
},
312312
},
313+
314+
{
315+
id: 'Ensure CoreSystem.settingsWithOverrides is valid',
316+
dependOnResultFrom: `convert CoreSystem.settingsWithOverrides`,
317+
canBeRunAutomatically: true,
318+
validate: async () => {
319+
const systems = await CoreSystem.findFetchAsync({
320+
$or: [
321+
{
322+
'settingsWithOverrides.defaults': { $exists: false },
323+
},
324+
{
325+
'settingsWithOverrides.overrides': { $exists: false },
326+
},
327+
],
328+
})
329+
330+
if (systems.length > 0) {
331+
return 'settings must be converted to an ObjectWithOverrides'
332+
}
333+
334+
return false
335+
},
336+
migrate: async () => {
337+
const systems = await CoreSystem.findFetchAsync({
338+
$or: [
339+
{
340+
'settingsWithOverrides.defaults': { $exists: false },
341+
},
342+
{
343+
'settingsWithOverrides.overrides': { $exists: false },
344+
},
345+
],
346+
})
347+
348+
for (const system of systems) {
349+
const newSettings = wrapDefaultObject<ICoreSystemSettings>({
350+
cron: {
351+
casparCGRestart: {
352+
enabled: false,
353+
},
354+
storeRundownSnapshots: {
355+
enabled: false,
356+
},
357+
},
358+
support: { message: '' },
359+
evaluationsMessage: { enabled: false, heading: '', message: '' },
360+
})
361+
362+
await CoreSystem.updateAsync(system._id, {
363+
$set: {
364+
settingsWithOverrides: {
365+
...newSettings,
366+
...system.settingsWithOverrides,
367+
},
368+
},
369+
})
370+
}
371+
},
372+
},
313373
])
314374

315375
interface PartialOldICoreSystem {

0 commit comments

Comments
 (0)