Skip to content

Commit 70228e2

Browse files
committed
wip: migration
1 parent 91d69ab commit 70228e2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

meteor/server/migration/X_X_X.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,41 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
187187
}
188188
},
189189
},
190+
191+
{
192+
id: `add studio settings allowHold & allowPieceDirectPlay`,
193+
canBeRunAutomatically: true,
194+
validate: async () => {
195+
const studios = await Studios.findFetchAsync({
196+
$or: [
197+
{ 'settings.allowHold': { $exists: false } },
198+
{ 'settings.allowPieceDirectPlay': { $exists: false } },
199+
],
200+
})
201+
202+
if (studios.length > 0) {
203+
return 'studios must have settings.allowHold and settings.allowPieceDirectPlay defined'
204+
}
205+
206+
return false
207+
},
208+
migrate: async () => {
209+
const studios = await Studios.findFetchAsync({
210+
$or: [
211+
{ 'settings.allowHold': { $exists: false } },
212+
{ 'settings.allowPieceDirectPlay': { $exists: false } },
213+
],
214+
})
215+
216+
for (const studio of studios) {
217+
// Populate the settings to be backwards compatible
218+
await Studios.updateAsync(studio._id, {
219+
$set: {
220+
'settings.allowHold': true,
221+
'settings.allowPieceDirectPlay': true,
222+
},
223+
})
224+
}
225+
},
226+
},
190227
])

0 commit comments

Comments
 (0)