mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-11-30 01:42:54 +01:00
Update migrate.ts
This commit is contained in:
parent
db4378415e
commit
d4bdb5d327
1 changed files with 29 additions and 0 deletions
|
@ -289,6 +289,20 @@ async function main() {
|
|||
});
|
||||
}
|
||||
|
||||
async function reMigrateUser(user: any) {
|
||||
const u = await _User.findOne({
|
||||
_id: new mongo.ObjectId(user.id)
|
||||
});
|
||||
const avatar = await DriveFiles.findOne(u.avatarId.toHexString());
|
||||
const banner = await DriveFiles.findOne(u.bannerId.toHexString());
|
||||
await Users.update(user.id, {
|
||||
avatarId: avatar.id,
|
||||
bannerId: banner.id,
|
||||
avatarUrl: avatar.url,
|
||||
bannerUrl: banner.url
|
||||
});
|
||||
}
|
||||
|
||||
const allUsersCount = await _User.count();
|
||||
for (let i = 0; i < allUsersCount; i++) {
|
||||
const user = await _User.findOne({}, {
|
||||
|
@ -404,6 +418,21 @@ async function main() {
|
|||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
const allActualUsersCount = await Users.count();
|
||||
for (let i = 0; i < allActualUsersCount; i++) {
|
||||
const [user] = await Users.find({
|
||||
take: 1,
|
||||
skip: i
|
||||
});
|
||||
try {
|
||||
await reMigrateUser(user);
|
||||
console.log(`RE:USER (${i + 1}/${allActualUsersCount}) ${user.id} ${chalk.green('DONE')}`);
|
||||
} catch (e) {
|
||||
console.log(`RE:USER (${i + 1}/${allActualUsersCount}) ${user.id} ${chalk.red('ERR')}`);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
Loading…
Reference in a new issue