Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions migrations/20251107223530-convert-release-string-null-to-null.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Convert payload.release equal to string "null" into real null
* across all per-project events collections (events:{projectId})
*/
module.exports = {
async up(db) {
const collections = await db.listCollections().toArray();
const targetCollections = collections
.map(c => c.name)
.filter(name => name && name.startsWith('events:'));

console.log(`Found ${targetCollections.length} events collections to normalize "null" string to null`);

for (const name of targetCollections) {
const coll = db.collection(name);

try {
const result = await coll.updateMany(
{ 'payload.release': 'null' },
{ $set: { 'payload.release': null } }
);

console.log(`[${name}] matched=${result.matchedCount}, modified=${result.modifiedCount}`);
} catch (e) {
console.error(`[${name}] failed to convert "null" string to null:`, e);
}
}
},

async down() {
console.log('Down migration is not implemented: cannot reliably restore original "null" string values.');
},
};
Loading