Skip to content

Commit 04b816e

Browse files
authored
fix: add migration to set default updatedBy (#2134)
1 parent 8a8fff0 commit 04b816e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const collections = [
2+
"Attachment",
3+
"Datablock",
4+
"Dataset",
5+
"Job",
6+
"OrigDatablock",
7+
"Policy",
8+
"Proposal",
9+
"PublishedData",
10+
"Sample",
11+
];
12+
13+
14+
module.exports = {
15+
async up(db, client) {
16+
for (const collectionName of collections) {
17+
await db
18+
.collection(collectionName)
19+
.updateMany(
20+
{ updatedBy: { $exists: false } },
21+
[{ $set: { updatedBy: "$createdBy" } }]
22+
);
23+
}
24+
},
25+
26+
async down(db, client) {
27+
// No path backward as it's not easy to find on down where updatedBy was added
28+
},
29+
};

0 commit comments

Comments
 (0)