Skip to content

Commit

Permalink
Skip generateKmqDataTables on migration disabled instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism committed Feb 2, 2024
1 parent b54a997 commit 4bf7163
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/seed/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ async function bootstrapDatabases(): Promise<void> {
}

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");
Expand Down
19 changes: 8 additions & 11 deletions src/seed/seed_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 4bf7163

Please sign in to comment.