forked from nrkno/sofie-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nrkno#231 from tv2/SOF-1410/moveMigrationAwayFromX…
…_X_X SOF-1410 Move migrations away from X_X_X file
- Loading branch information
Showing
4 changed files
with
78 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { addMigrationSteps } from './databaseMigration' | ||
import { ShowStyleVariant, ShowStyleVariants } from '../../lib/collections/ShowStyleVariants' | ||
import { PieceInstances } from '../../lib/collections/PieceInstances' | ||
import { TriggeredActions } from '../../lib/collections/TriggeredActions' | ||
|
||
export const addSteps = addMigrationSteps('46.1.0', [ | ||
{ | ||
id: 'Add missing ranks to ShowStyleVariants', | ||
canBeRunAutomatically: true, | ||
validate: () => { | ||
return ( | ||
ShowStyleVariants.find({ | ||
_rank: { $exists: false }, | ||
}).count() > 0 | ||
) | ||
}, | ||
migrate: () => { | ||
ShowStyleVariants.find({ | ||
_rank: { $exists: false }, | ||
}).forEach((variant: ShowStyleVariant, index: number) => { | ||
ShowStyleVariants.upsert(variant._id, { | ||
$set: { | ||
_rank: index, | ||
}, | ||
}) | ||
}) | ||
}, | ||
}, | ||
{ | ||
id: 'Change PieceInstances.dynamicallyInserted type', | ||
canBeRunAutomatically: true, | ||
validate: () => { | ||
return ( | ||
PieceInstances.find({ | ||
dynamicallyInserted: { $type: 'number' }, | ||
}).count() > 0 | ||
) | ||
}, | ||
migrate: () => { | ||
PieceInstances.find({ | ||
dynamicallyInserted: { $type: 'number' }, | ||
}).forEach((pieceInstance) => { | ||
if (typeof pieceInstance.dynamicallyInserted !== 'number') { | ||
return | ||
} | ||
PieceInstances.update(pieceInstance._id, { | ||
$set: { dynamicallyInserted: { time: pieceInstance.dynamicallyInserted } }, | ||
}) | ||
}) | ||
}, | ||
}, | ||
{ | ||
id: 'Add "useNameForDisplay" attribute to TriggeredActions', | ||
canBeRunAutomatically: true, | ||
validate: () => { | ||
return ( | ||
TriggeredActions.find({ | ||
useNameForDisplay: { $exists: false }, | ||
}).count() > 0 | ||
) | ||
}, | ||
migrate: () => { | ||
TriggeredActions.find({}).forEach((action) => { | ||
TriggeredActions.update(action._id, { $set: { useNameForDisplay: false } }) | ||
}) | ||
}, | ||
}, | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { addMigrationSteps } from './databaseMigration' | ||
import { createMigrationsForAddingMissingIdsInSelectFromColumnEntries } from './addMissingIdsForSelectFromColumns' | ||
|
||
export const addSteps = addMigrationSteps('46.2.1', [...createMigrationsForAddingMissingIdsInSelectFromColumnEntries()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters