Skip to content

Commit af0d5a9

Browse files
committed
fix: convert release 'null' to null
1 parent 2a61c10 commit af0d5a9

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Convert payload.release equal to string "null" into real null
3+
* across all per-project events collections (events:{projectId})
4+
*/
5+
module.exports = {
6+
async up(db) {
7+
const collections = await db.listCollections().toArray();
8+
const targetCollections = collections
9+
.map(c => c.name)
10+
.filter(name => name && name.startsWith('events:'));
11+
12+
console.log(`Found ${targetCollections.length} events collections to normalize "null" string to null`);
13+
14+
for (const name of targetCollections) {
15+
const coll = db.collection(name);
16+
17+
try {
18+
const result = await coll.updateMany(
19+
{ 'payload.release': 'null' },
20+
{ $set: { 'payload.release': null } }
21+
);
22+
23+
console.log(`[${name}] matched=${result.matchedCount}, modified=${result.modifiedCount}`);
24+
} catch (e) {
25+
console.error(`[${name}] failed to convert "null" string to null:`, e);
26+
}
27+
}
28+
},
29+
30+
async down() {
31+
console.log('Down migration is not implemented: cannot reliably restore original "null" string values.');
32+
},
33+
};

0 commit comments

Comments
 (0)