From 31f5254fb3d7ac8530946cdf557e0833f8072bd2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 29 Jul 2024 15:37:45 -0500 Subject: [PATCH] Clear timeouts in tag queries migration --- src/db/migrations/029_tag_queries.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/db/migrations/029_tag_queries.ts b/src/db/migrations/029_tag_queries.ts index 932b9599..5a27d720 100644 --- a/src/db/migrations/029_tag_queries.ts +++ b/src/db/migrations/029_tag_queries.ts @@ -11,12 +11,13 @@ export async function up(db: Kysely): Promise { .addColumn('created_at', 'integer', (col) => col.notNull()) .execute(); - setTimeout(() => { + let iid: number | undefined; + const tid = setTimeout(() => { console.warn( 'Recreating the tags table to boost performance. Depending on the size of your database, this could take a very long time, even as long as 2 days!', ); const emojis = ['⚡', '🐛', '🔎', '😂', '😅', '😬', '😭', '🙃', '🤔', '🧐', '🧐', '🫠']; - setInterval(() => { + iid = setInterval(() => { const emoji = emojis[Math.floor(Math.random() * emojis.length)]; console.info(`Recreating tags table... ${emoji}`); }, 60_000); @@ -32,6 +33,9 @@ export async function up(db: Kysely): Promise { nostr_tags as t LEFT JOIN nostr_events e on t.event_id = e.id; `.execute(db); + clearTimeout(tid); + if (iid) clearInterval(iid); + // Drop the old table and rename it. await db.schema.dropTable('nostr_tags').execute(); await db.schema.alterTable('nostr_tags_new').renameTo('nostr_tags').execute();