From 4bf716322f41abf4b26d477fc1ab60efd5e6b87e Mon Sep 17 00:00:00 2001 From: Brian Le Date: Fri, 2 Feb 2024 21:37:38 +0000 Subject: [PATCH] Skip generateKmqDataTables on migration disabled instances --- src/seed/bootstrap.ts | 8 +++++++- src/seed/seed_db.ts | 19 ++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/seed/bootstrap.ts b/src/seed/bootstrap.ts index a4d29f10a..58e3fd2b1 100644 --- a/src/seed/bootstrap.ts +++ b/src/seed/bootstrap.ts @@ -207,7 +207,13 @@ async function bootstrapDatabases(): Promise { } if (process.env.NODE_ENV === EnvType.PROD) { - await generateKmqDataTables(db); + if (!KmqConfiguration.Instance.disallowMigrations()) { + await generateKmqDataTables(db); + } else { + logger.info( + "Skipping generateKmqDataTables due to disabled migrations", + ); + } } logger.info("Cleaning up stale data"); diff --git a/src/seed/seed_db.ts b/src/seed/seed_db.ts index b38c608cc..6b6ed4414 100644 --- a/src/seed/seed_db.ts +++ b/src/seed/seed_db.ts @@ -99,6 +99,7 @@ async function replaceBetterAudioSongs( "b.vlink as better_audio_link", ]) .where("b.vlink", "is not", null) + .$narrowType<{ better_audio_link: string }>() .execute(); for (const betterAudioSong of songsWithBetterAudioCounterpart) { @@ -109,17 +110,13 @@ async function replaceBetterAudioSongs( .execute(); // replace main video with better audio entry - if (betterAudioSong.better_audio_link) { - // TODO: this null check shouldn't be needed, but Kysely does not narrow types automatically - // can be removed when .$narrowType is available - await db - .updateTable("app_kpop") - .where("id", "=", betterAudioSong.original_id) - .set({ - vlink: betterAudioSong.better_audio_link, - }) - .execute(); - } + await db + .updateTable("app_kpop") + .where("id", "=", betterAudioSong.original_id) + .set({ + vlink: betterAudioSong.better_audio_link, + }) + .execute(); } }