This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import type { Db, MongoClient } from 'mongodb';
module.exports = {
async up(db: Db, client: MongoClient) {
// 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}});
const collectionNames = (await db.collections()).map(
(c) => c.collectionName
);
if (!collectionNames.includes('p_simplenotifies')) {
console.log('not init `p_simplenotifies`, ignored.');
return;
}
const collection = db.collection('p_simplenotifies');
const list = await collection
.find({
type: null,
})
.toArray();
console.log(`待处理记录: ${list.length}`);
for (const item of list) {
await collection.updateOne(
{
_id: item._id,
},
{
$set: {
type: 'group',
},
}
);
console.log('已更新:', item._id);
}
},
async down(db: Db, client: MongoClient) {
// TODO write the statements to rollback your migration (if possible)
// Example:
// await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: false}});
},
};