-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path20240920111733-dataset-unified-schema.js
47 lines (45 loc) · 1.28 KB
/
20240920111733-dataset-unified-schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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",
},
},
]);
},
};