From c2a7ae6fa35180ce9351ccf51b45322214d52745 Mon Sep 17 00:00:00 2001 From: Dragory Date: Mon, 19 Feb 2018 00:52:47 +0200 Subject: [PATCH] legacyMigrator: ahem, one more fix --- src/legacy/legacyMigrator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/legacy/legacyMigrator.js b/src/legacy/legacyMigrator.js index dd18eb9..cf70dca 100644 --- a/src/legacy/legacyMigrator.js +++ b/src/legacy/legacyMigrator.js @@ -70,7 +70,7 @@ async function shouldMigrate() { async function migrateOpenThreads() { const bot = new Eris.Client(config.token); - return new Promise(resolve => { + const toReturn = new Promise(resolve => { bot.on('ready', async () => { const oldThreads = await jsonDb.get('threads', []); @@ -100,7 +100,7 @@ async function migrateOpenThreads() { const threadId = await threads.createThreadInDB(newThread); - await trx('thread_messages').insert({ + await knex('thread_messages').insert({ thread_id: threadId, message_type: THREAD_MESSAGE_TYPE.LEGACY, user_id: oldThread.userId, @@ -116,6 +116,10 @@ async function migrateOpenThreads() { bot.connect(); }); + + await toReturn; + + bot.disconnect(); } async function migrateLogs() {