-
Notifications
You must be signed in to change notification settings - Fork 25
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 #1414 from SciCatProject/swap-4073-single-dataset-…
…schema refactor: prep for unified dataset schema
- Loading branch information
Showing
25 changed files
with
1,224 additions
and
288 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,47 @@ | ||
module.exports = { | ||
async up(db, client) { | ||
// TODO write your migration here. | ||
// See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script | ||
// Example: | ||
// await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}}); | ||
await db.collection("Dataset").updateMany({}, [ | ||
{ | ||
$set: { | ||
proposalIds: ["$proposalId"], | ||
instrumentIds: ["$instrumentId"], | ||
sampleIds: ["$sampleId"], | ||
}, | ||
}, | ||
]); | ||
await db.collection("Dataset").updateMany({ type: "derived" }, [ | ||
{ | ||
$set: { | ||
principalInvestigator: "$investigator", | ||
}, | ||
}, | ||
]); | ||
}, | ||
|
||
async down(db, client) { | ||
// TODO write the statements to rollback your migration (if possible) | ||
// Example: | ||
// await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: false}}); | ||
|
||
await db.collection("Dataset").updateMany({}, [ | ||
{ | ||
$set: { | ||
proposalId: "$proposalIds[0]", | ||
instrumentId: "$instrumentId[0]", | ||
sampleId: "$sampleId[0]", | ||
}, | ||
}, | ||
]); | ||
await db.collection("Dataset").updateMany({ type: "derived" }, [ | ||
{ | ||
$set: { | ||
investigator: "$principalInvestigator", | ||
}, | ||
}, | ||
]); | ||
}, | ||
}; |
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
Oops, something went wrong.