summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-04-09 18:45:21 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-04-09 18:45:21 +0900
commitd44fc3db2f3160f487e622d9c578304c60578783 (patch)
tree435f0baa6104cf0d3e0ed7200335b55d94c2b371 /src
parentUpdate migrate.ts (diff)
downloadmisskey-d44fc3db2f3160f487e622d9c578304c60578783.tar.gz
misskey-d44fc3db2f3160f487e622d9c578304c60578783.tar.bz2
misskey-d44fc3db2f3160f487e622d9c578304c60578783.zip
Update migrate.ts
Diffstat (limited to 'src')
-rw-r--r--src/migrate.ts39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/migrate.ts b/src/migrate.ts
index ceaec4185d..7ee699116b 100644
--- a/src/migrate.ts
+++ b/src/migrate.ts
@@ -20,6 +20,7 @@ import { genId } from './misc/gen-id';
import { Poll } from './models/entities/poll';
import { PollVote } from './models/entities/poll-vote';
import { NoteFavorite } from './models/entities/note-favorite';
+import { NoteReaction } from './models/entities/note-reaction';
const u = (config as any).mongodb.user ? encodeURIComponent((config as any).mongodb.user) : null;
const p = (config as any).mongodb.pass ? encodeURIComponent((config as any).mongodb.pass) : null;
@@ -51,6 +52,7 @@ const _Note = db.get<any>('notes');
const _Following = db.get<any>('following');
const _PollVote = db.get<any>('pollVotes');
const _Favorite = db.get<any>('favorites');
+const _NoteReaction = db.get<any>('noteReactions');
const getDriveFileBucket = async (): Promise<mongo.GridFSBucket> => {
const db = await nativeDbConn();
const bucket = new mongo.GridFSBucket(db, {
@@ -69,6 +71,7 @@ async function main() {
const Polls = getRepository(Poll);
const PollVotes = getRepository(PollVote);
const NoteFavorites = getRepository(NoteFavorite);
+ const NoteReactions = getRepository(NoteReaction);
async function migrateUser(user: any) {
await Users.insert({
@@ -255,6 +258,16 @@ async function main() {
});
}
+ async function migrateNoteReaction(reaction: any) {
+ await NoteReactions.save({
+ id: reaction._id.toHexString(),
+ createdAt: reaction.createdAt,
+ noteId: reaction.noteId.toHexString(),
+ userId: reaction.userId.toHexString(),
+ reaction: reaction.reaction
+ });
+ }
+
const allUsersCount = await _User.count();
for (let i = 0; i < allUsersCount; i++) {
const user = await _User.findOne({}, {
@@ -290,9 +303,9 @@ async function main() {
});
try {
await migrateDriveFolder(folder);
- console.log(`DRIVEFOLDER (${i + 1}/${allDriveFoldersCount}) ${folder._id} ${chalk.green('DONE')}`);
+ console.log(`FOLDER (${i + 1}/${allDriveFoldersCount}) ${folder._id} ${chalk.green('DONE')}`);
} catch (e) {
- console.log(`DRIVEFOLDER (${i + 1}/${allDriveFoldersCount}) ${folder._id} ${chalk.red('ERR')}`);
+ console.log(`FOLDER (${i + 1}/${allDriveFoldersCount}) ${folder._id} ${chalk.red('ERR')}`);
console.error(e);
}
}
@@ -304,9 +317,9 @@ async function main() {
});
try {
await migrateDriveFile(file);
- console.log(`DRIVEFILE (${i + 1}/${allDriveFilesCount}) ${file._id} ${chalk.green('DONE')}`);
+ console.log(`FILE (${i + 1}/${allDriveFilesCount}) ${file._id} ${chalk.green('DONE')}`);
} catch (e) {
- console.log(`DRIVEFILE (${i + 1}/${allDriveFilesCount}) ${file._id} ${chalk.red('ERR')}`);
+ console.log(`FILE (${i + 1}/${allDriveFilesCount}) ${file._id} ${chalk.red('ERR')}`);
console.error(e);
}
}
@@ -336,9 +349,9 @@ async function main() {
});
try {
await migratePollVote(vote);
- console.log(`POLLVOTE (${i + 1}/${allPollVotesCount}) ${vote._id} ${chalk.green('DONE')}`);
+ console.log(`VOTE (${i + 1}/${allPollVotesCount}) ${vote._id} ${chalk.green('DONE')}`);
} catch (e) {
- console.log(`POLLVOTE (${i + 1}/${allPollVotesCount}) ${vote._id} ${chalk.red('ERR')}`);
+ console.log(`VOTE (${i + 1}/${allPollVotesCount}) ${vote._id} ${chalk.red('ERR')}`);
console.error(e);
}
}
@@ -356,6 +369,20 @@ async function main() {
console.error(e);
}
}
+
+ const allNoteReactionsCount = await _NoteReaction.count();
+ for (let i = 0; i < allNoteReactionsCount; i++) {
+ const reaction = await _NoteReaction.findOne({}, {
+ skip: i
+ });
+ try {
+ await migrateNoteReaction(reaction);
+ console.log(`REACTION (${i + 1}/${allNoteReactionsCount}) ${reaction._id} ${chalk.green('DONE')}`);
+ } catch (e) {
+ console.log(`REACTION (${i + 1}/${allNoteReactionsCount}) ${reaction._id} ${chalk.red('ERR')}`);
+ console.error(e);
+ }
+ }
}
main();